Reputation: 4369
well my Tomcat (run via Eclipse) seems to fail to load the SQL Server driver lib:
java.lang.NullPointerException
java.lang.RuntimeException
at org.ktu.gdia.core.MainController.processFile(MainController.java:132)
at org.ktu.gdia.core.MainController.run(MainController.java:57)
java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://isd.ktu.lt:1433;DatabaseName=LN2012_bakDB2
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.apache.tomcat.dbcp.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:75)
at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.tomcat.dbcp.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1185)
at org.apache.tomcat.dbcp.dbcp.PoolingDriver.connect(PoolingDriver.java:180)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.ktu.gdia.database.DbActions.openConn(DbActions.java:64)
at org.ktu.gdia.core.MainController.processFile(MainController.java:134)
at org.ktu.gdia.core.MainController.run(MainController.java:57)
Exception in thread "Thread-2" java.lang.NullPointerException
at org.ktu.gdia.database.GenForestDatabase.personExists(GenForestDatabase.java:178)
at org.ktu.gdia.core.MainController.processFile(MainController.java:158)
at org.ktu.gdia.core.MainController.run(MainController.java:57)
the sqljdbc.jar and sqljdb4.jar and jtds-1.3.0.jar are in the Tomcat/lib directory. I'm using Tomcat 7. Is it possible, that Eclipse makes Tomcat use a different lib directory then the one in the Tomcat 7 which it is supposed to use?
Upvotes: 0
Views: 434
Reputation: 308988
You don't need all of those JARs, just the one that you actually want to load. It appears to the Microsoft driver, not jTDS.
I don't know what Eclipse is doing, but Tomcat expects JDBC driver JARs to be loaded from its /lib directory.
I don't agree that the problem is failing to load the driver. "No suitable driver" usually means that the URL syntax in the connection string is incorrect.
You have
jdbc:microsoft:sqlserver://isd.ktu.lt:1433;DatabaseName=LN2012_bakDB2
This URL suggests the following format:
jdbc:sqlserver://host:1433;databaseName=dbNameHere;integratedSecurity=true;
If the URL appears to be right, I'd start checking other things:
isd.ktu.lt
from the server where you run your Java app? If you can't see that server Java won't, either.Here's configuration from an app that successfully connects to SQL Server:
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
<property name="url" value="jdbc:sqlserver://host:port;databaseName=db"/>
Upvotes: 1