It's not a secret anymore!*
The moose likes Tomcat and the fly likes Connection pooling question: Can MySQL Conector/J be in WEB-INF/lib? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Connection pooling question: Can MySQL Conector/J be in WEB-INF/lib?" Watch "Connection pooling question: Can MySQL Conector/J be in WEB-INF/lib?" New topic
Author

Connection pooling question: Can MySQL Conector/J be in WEB-INF/lib?

Bojan Tomic
Greenhorn

Joined: Apr 08, 2008
Posts: 25
I need to know if it is possible to use connection pooling in Tomcat without having the JDBC driver (MySQL Connector/J in my case) inside commons/lib directory, but inside your WEB-INF/lib instead?
I have tried doing this, of course, and it doesn't seem to work, but I can't be sure if it is a problem with my configuration. With the driver present in commons/lib, it works as normal.
I searched around quite a bit, but I keep running into conflicting information. Is there a chance of conflict if I put the JDBC driver in both commons/lib and WEB-INF lib?
For the reference I am using Tomcat 6.0.16 and Connector/J 5.1.6. My context.xml is as follows:

Any thoughts on this?

[ October 13, 2008: Message edited by: Veggen Skrikk ]
[ October 13, 2008: Message edited by: Veggen Skrikk ]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Originally posted by Veggen Skrikk:
I need to know if it is possible to use connection pooling in Tomcat without having the JDBC driver (MySQL Connector/J in my case) inside commons/lib directory, but inside your WEB-INF/lib instead?


I would say no. If you want the container to manage your connections, the JDBC driver has to be in the container's classpath, not the application's.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Bhaskar Rao
Greenhorn

Joined: Apr 25, 2005
Posts: 23
Hi,

Even if you do have the MySQL driver at the web app level at WEB-INF/lib Tomcat will use the driver located at TOMCAT_HOME/common/lib. The driver located at WEB-INF/lib will not be 'visible' to Tomcat classes.

I dont see any conflict if you do have the driver at both locations, but what is the need for the driver to be available at the web app level?
Bojan Tomic
Greenhorn

Joined: Apr 08, 2008
Posts: 25
Ok people, thanks a lot for clearing it up for me! I'm grateful.
Oh, and I asked if driver being present on both location would cause a conflict only because I accidentaly shipped an application with a copy of the driver in WEB-INF/lib and I was afraid it might cause troubles.

Thanks again.
 
 
subject: Connection pooling question: Can MySQL Conector/J be in WEB-INF/lib?
 
Similar Threads
cannot connect to database using JNDI
tomcat and db connectivity
cannot connect to database using JNDI
Datasource Problem
(Application scoped) DB connection pooling