wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Webapp can't load sql driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Webapp can Watch "Webapp can New topic
Author

Webapp can't load sql driver

Andrei Antonescu
Ranch Hand

Joined: Jul 08, 2010
Posts: 75
Hello all,
I have a tomcat 7 on cent os and I use sqljdbc4-SNAPSHOT.jar as a driver to connect to Microsoft SQL Server 2008.
I deployed the solution but i got execeptions when I tried to load the SQL driver (at DriverManager). I copied the driver's jar in tomcat's lib folder and the problem was fixed.

Can you please help me understand why moving the jar in the tomcat's folder solved the problem?

Thanks in advance
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

It depends on where you copied it from. And if there were other copies in other classpaths.

JDBC drivers should almost always be copied to the TOMCAT_HOME/lib directory and not made part of the WARs, however. Take that as a near-universal rule. For one thing, the connection pooling is normally provided by the server, so the driver has to be in the server classpath, which means TOMCAT_HOME/lib.

It might be just a co-incidence that you got the "Connection reset". Network-related problems usually cause that. However, if you DID have 2 copies of the driver in the system, differing access paths could have resulted in internal inconsistencies, like where one copy sent out the request, and the other copy listened for it (but didn't have the context of the sender!).


Customer surveys are for companies who didn't pay proper attention to begin with.
 
wood burning stoves
 
subject: Webapp can't load sql driver