tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From A Df <>
Subject Re: Tomcat 6 not working with JDBC driver for MySQL
Date Thu, 28 Jul 2011 19:58:19 GMT
Hello Everyone:


I finally got it to work. Thanks to everyone that helped!! BTW, should I put the word solved
in the subject?

I had to create a Base class to setup the connection and then have another class extend it.
The subclass only dealt with methods for executing statements. See more at:

Here is my latest configuration and software details:

java version 1.6.0_26
Apache Tomcat 6.0.26

JDBC Driver:
MySQL Connector/J JDBC Driver (mysql-connector-java-5.1.17-bin.jar) is in $CATALINA_HOME/lib

I am also posting the content of my other files as follows:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" crossContext="true" path="/TweetCollector" reloadable="true">
  <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="8" maxIdle="4"
name="jdbc/myDB" password="administrator" type="javax.sql.DataSource" url="jdbc:mysql://"
username="root" validationQuery="SELECT 1"/>

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="" xmlns:xsi=""
    Resource reference to a factory for java.sql.Connection
    instances that may be used for talking to a particular
    database that is configured in the Context
    configurartion for the web application.

Thanks again :D

A Df

>From: Christopher Schultz <>
>To: Tomcat Users List <>
>Sent: Wednesday, 27 July 2011, 23:38
>Subject: Re: Tomcat 6 not working with JDBC driver for MySQL
>Hash: SHA1
>To whom it may concern,
>On 7/25/2011 4:40 PM, A Df wrote:
>> I have added the MySQL Connector/J JDBC Driver to the
>> $CATALINA_HOME/lib directory
>> I have modify the web application deployment descriptor
>> (/WEB-INF/web.xml)
>> <resource-ref> <res-ref-name> jdbc/myDB </res-ref-name> <res-type>

>> javax.sql.DataSource </res-type> <res-auth> Container </res-auth>

>> </resource-ref>
>> I have modified the XML file (META-INF/context.xml) found in the
>> project’s folders <Context crossContext="true" debug="5"
>> docBase="TweetCollector" antiJARLocking="true"
>> path="/TweetCollector" reloadable="true">
>Okay, the following attributes should not be used:
>- - debug (ignored)
>- - docBase (context.xml is already in a WAR/WARdir)
>- - path (Tomcat determines the deployment path from the WAR/WARdir name)
>> <Resource name="jdbc/myDB" auth="Container" 
>> type="javax.sql.DataSource" username="root" password="administrator" 
>> driverClassName="com.mysql.jdbc.Driver" 
>> url="jdbc:mysql://localhost:3306/myDB?autoReconnect=true" 
>> maxActive="8" maxIdle="4"/>
>That looks good to me.
>> The connection in the log prints as 
>> jdbc:mysql://localhost:3306/myDB?autoReconnect=true,
>> UserName=root@localhost, MySQL-AB JDBC Driver
>What connection in what log?
>> However, it gives the error: 
>> org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC
>> driver OR java.sql.SQLException: No suitable driver
>Do you have JDBS drivers in multiple places?
>Try stopping Tomcat, deleting the whole "work" directory and any cached
>deployment descriptors under conf/Catalina/localhost/[webapp].xml
>> Is it that the version for the server needs to match specific
>> version for MySQL and its driver?
>> How can I solve the JDBC issue? I have tried so many posts and made 
>> so many changes that i am really frustrated and dont know what else 
>> to do. Thanks.
>Historically, that message ("No suitable driver") means that your
>configuration is slightly wrong. Since Tomcat caches the deployment
>descriptor, yours might be out-of-date, hence my suggestions above.
>- -chris
>Version: GnuPG v1.4.10 (MingW32)
>Comment: Using GnuPG with Mozilla -
>To unsubscribe, e-mail:
>For additional commands, e-mail:
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message