I am using Tomcat and Java (through Eclipse) and SQL Server 2008 R2
I am getting
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of
class '' for connect URL 'null'
I also tried deploying to Tomcat 7 and I got exactly the same error. (I made sure that in this case the sqljdbc4.jar was in the lib directory of Tomcat, rather than just in the WAR)
Can anyone help? Thanks!
My code is as follows:
Server.xml
<GlobalNamingResources>
<Resource type="javax.sql.DataSource" auth="Container"
name="jdbc/charmDB"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost:1433;databaseName=CH;
integratedSecurity=true"
/>
Web.xml
<resource-ref>
<description>CH Database</description>
<res-ref-name>jdbc/charmDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Java code
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/charmDB");
Connection con = ds.getConnection();