Jacob Kjome wrote:
Hello Mehdi,

If you are using DBCP connection pooling, your driver *must* exist in
CATALINA_HOME/common/lib.  This is because the DBCP libraries exist in
common/lib and the fact that classes from common/lib do not have
access to the child classloader in WEB-INF/lib.  However, your classes
in WEB-INF/lib *does* have access to the parent classloader in
common/lib.

So, put it in common/lib and it should work.

dont' forget to add ?autoReconnect=true to your connection url config
for MySQL.
After reading this a few days ago, I decided to ask my sysadmin to move my mysql-connector-java-2.0.14-bin.jar file from my webapp's WEB-INF/lib to $CATALINA_HOME/common/lib, and he did. After we restarted Tomcat, my webapp wouldn't work, so, to confirm that it wasn't an application-level problem, I put the mysql-connector-java-2.0.14-bin.jar file back in WEB-INF/lib (of my webapp). The driver still can't be found for some reason.

Is there something that I'm supposed to do to "register" the driver? Does it change the JDBC url if you move it to common/lib for some reason?


Erik





Jake

Wednesday, January 22, 2003, 9:13:39 AM, you wrote:


MNbc> Hello all,

MNbc> i have been breaking my brain trying to get connection pooling, using
MNbc> Tomcat 4.1.12's build in dbcp, with mySQL 3.23.

MNbc> I have followed the instructions on the how this should be done, and I am
MNbc> getting an exception when I try to get a connection .. (like many other
MNbc> people it seems)..  If anyone has solved this problem.. or has a link to a
MNbc> forum where this problem is answered please let me know..

MNbc> I have downloaded mysql-connector-java-2.0.14.zip

MNbc> I unzipped it and copied :
MNbc> *  the contents of WEB-INF/lib to my lib folder
MNbc> * contents of com to my WEB-INF/classes folder
MNbc> * contents of org to my WEB-INF/classes folder (this *does* contain
MNbc> org.gjt.mm.mysql.Driver)

MNbc> This does not work.  My jsp test code follows, and the Exception occurs on
MNbc> getConnection()...

MNbc> <%@ page language="java" import="java.sql.*, javax.sql.*, javax.naming.*"
MNbc> errorPage="error.jsp" %>

MNbc> <%
MNbc>       Context initContext = new InitialContext();
MNbc>       Context envContext  = (Context)initContext.lookup("java:/comp/env");
MNbc>       DataSource ds = (DataSource)envContext.lookup("jdbc/mehdi");
MNbc>       Connection conn = ds.getConnection();

%>>

MNbc> Exception is

MNbc> java.sql.SQLException: Cannot load JDBC driver class
MNbc> 'org.gjt.mm.mysql.Driver'

MNbc> SERVER.XML

MNbc>         <Context path="/mysql" docBase="mysql" debug="0" reloadable="true">

MNbc>  <Logger className="org.apache.catalina.logger.FileLogger"
MNbc>              prefix="localhost_DBTest_log." suffix=".txt"
MNbc>              timestamp="true"/>

MNbc>   <Resource name="jdbc/mehdi"
MNbc>                auth="Container"
MNbc>                type="javax.sql.DataSource"/>

MNbc>   <ResourceParams name="jdbc/mehdi">
MNbc>     <parameter>
MNbc>       <name>factory</name>
MNbc>       <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
MNbc>     </parameter>

MNbc>     <!-- Maximum number of dB connections in pool. Make sure you
MNbc>          configure your mysqld max_connections large enough to handle
MNbc>          all of your db connections. Set to 0 for no limit.
MNbc>          -->
MNbc>     <parameter>
MNbc>       <name>maxActive</name>
MNbc>       <value>100</value>
MNbc>     </parameter>

MNbc>     <!-- Maximum number of idle dB connections to retain in pool.
MNbc>          Set to 0 for no limit.
MNbc>          -->
MNbc>     <parameter>
MNbc>       <name>maxIdle</name>
MNbc>       <value>30</value>
MNbc>     </parameter>

MNbc>     <!-- Maximum time to wait for a dB connection to become available
MNbc>          in ms, in this example 10 seconds. An Exception is thrown if
MNbc>          this timeout is exceeded.  Set to -1 to wait indefinitely.
MNbc>          -->
MNbc>     <parameter>
MNbc>       <name>maxWait</name>
MNbc>       <value>10000</value>
MNbc>     </parameter>

MNbc>     <!-- MySQL dB username and password for dB connections  -->
MNbc>     <parameter>
MNbc>      <name>username</name>
MNbc>      <value>mehdi</value>
MNbc>     </parameter>
MNbc>     <parameter>
MNbc>      <name>password</name>
MNbc>      <value>mypass</value>
MNbc>     </parameter>

MNbc>     <!-- Class name for mm.mysql JDBC driver -->
MNbc>     <parameter>
MNbc>        <name>driverClassName</name>
MNbc>        <value>org.gjt.mm.mysql.Driver</value>
MNbc>     </parameter>

MNbc>     <!-- The JDBC connection url for connecting to your MySQL dB.
MNbc>          The autoReconnect=true argument to the url makes sure that the
MNbc>          mm.mysql JDBC Driver will automatically reconnect if mysqld closed
MNbc> the
MNbc>          connection.  mysqld by default closes idle connections after 8
MNbc> hours.
MNbc>          -->
MNbc>     <parameter>
MNbc>       <name>url</name>
MNbc>       <value>jdbc:mysql://localhost:3306/mehdi?autoReconnect=true</value>
MNbc>     </parameter>
MNbc>   </ResourceParams>

MNbc>         </Context>


MNbc> running out of time, and hair.

MNbc> Thanks,

MNbc> Med




MNbc> --
MNbc> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
MNbc> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to