Using Tomcat Admin DSN and jdbc
Ok so I have a normal jdbc connection hard coded into my DAOFactory class that works fine.
try{
String DBURL ="db url"
DriverManager.registerDriver(new SQLServerDriver());
Connection con = DriverManager.getConnection(DBURL);
return con;
}catch(){
exection code
}
Since it's not good to hard code the url as a string I wanted to use a DSN in Tomcat. I've tried adapting the tutorial from [url]http://tomcat.apache.org/tomcat-4.1-doc/jndi-datasource-examples-howto.html [/url]to work with SQL Server but I get a NoInitialContextException. I know the driver is in the class path because it has no problem connecting. The problem is referencing the DSN entry in the class file.
It throws the NoInitialContextError on this line
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/BES")
I have edited my server.xml to include
<Resource
name="jdbc/BES"
type"javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
username="myname"
password="mypass"
url="jdbc:sqlserver://servername:1433;databaseName=db_name"/>
inside the GlobalNamingResources tag.
Can anyone tell me what I'm doing wrong or point me to a guide on how to use the Tomcat Admin to create DSN and use them to get a java connection.
Much Appreciated.

