This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Webapp can Watch "Webapp can New topic

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: 17161

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!).

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Webapp can't load sql driver
It's not a secret anymore!