Unable to create class 'JDBC driver' to connect 'null' URL: Tomcat & SQL Server JDBC driver

I tried everything that I can find there, if someone can help me, I will be eternally grateful (and much more free in due time).

Basically, I have an error in Tomcat 7.0 (both when starting in Eclipse and through startup.bat) that says this as soon as my dynamic web applications start receiving data:

Cannot create JDBC driver of class '' for connect URL 'null' java.lang.NullPointerException at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507) at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476) at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307) 

I have a sqljdbc4.jar file in my tomcat \ lib directory. I also tried putting this in my WEB-INF / lib and even in my JDK lib directories. I do not think sqljdbc.jar will work as it is for older JDK / JREs than mine.

I heard that the context.xml and web.xml files are critical to work.

snippet web.xml:

 <resource-ref> <description>LBI DB Connection</description> <res-ref-name>jdbc/LBIDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> <resource-ref> <description>OR DB Connection</description> <res-ref-name>jdbc/ORDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> 

context.xml

 <Context> <!-- Default set of monitored resources --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <Resource name="jdbc/LBIDB" auth="Container" type="javax.sql.DataSource" username="***" password="***" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver:localhost;DatabaseName=YYBackOffice;SelectMethod=cursor;" maxActive="8" maxIdle="4"/> <Resource name="jdbc/ORDB" auth="Container" type="javax.sql.DataSource" username="***" password="***" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver:localhost;DatabaseName=XXBackOffice;SelectMethod=cursor;" maxActive="8" maxIdle="4"/> 

The Context tab ultimately has a closing tab.

Please, help! If you need more information, please let me know. Also, I'm not sure which context.xml file should be changed, there are 2 in Tomcat directories, one in the / conf folder and one in the webapps / appname / META-INF folder. Sorry if this sounds like I'm a little rookie because I am!

In addition, I saw many different examples of url = "..." of the context.xml part, some of which include port numbers. I tried several things on the Internet, but nothing works (nothing helps online, this is my exact data environment, I also believe that it is difficult that this application requests two different databases at a given time).

Thoughts?

+7
source share
2 answers
+7
source

In tomcat 6.0.36, it's quite the opposite:

CATALINA_HOME/conf/Catalina/your_host/context.xml

will take a given value compared to

YourApplication/WebContent/META-INF/

After putting the data after the fragment inside the Context-Tag in Catalina/your_host it worked in my case:

 <WatchedResource>WEB-INF/web.xml</WatchedResource> <Resource name="jdbc/your_db" auth="Container" type="javax.sql.DataSource" maxActive="50" maxIdle="30" maxWait="10000" username="your_usr" password="your_pwd" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://your_host:3306/your_db"/> 

See Tomcat documentation at http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

+3
source

All Articles