tomcat-users mailing list archives

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

[SOLVED]

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:
http://forums.netbeans.org/viewtopic.php?p=110485


Here is my latest configuration and software details:

Using:
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
directory

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

content.xml
Code:
<?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://127.0.0.1/myDB?autoReconnect=true"
username="root" validationQuery="SELECT 1"/>
</Context>


web.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <resource-ref>
        <description>
    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.
        </description>
        <res-ref-name>
    jdbc/myDB
        </res-ref-name>
        <res-type>
    javax.sql.DataSource
        </res-type>
        <res-auth>
    Container
        </res-auth>
    </resource-ref>
</web-app>

Thanks again :D

Cheers,
A Df




>________________________________
>From: Christopher Schultz <chris@christopherschultz.net>
>To: Tomcat Users List <users@tomcat.apache.org>
>Sent: Wednesday, 27 July 2011, 23:38
>Subject: Re: Tomcat 6 not working with JDBC driver for MySQL
>
>-----BEGIN PGP SIGNED MESSAGE-----
>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
>
>Good.
>
>> 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>
>
>Okay.
>
>> 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?
>
>No.
>
>> 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
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.4.10 (MingW32)
>Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
>iEYEARECAAYFAk4wk3kACgkQ9CaO5/Lv0PB7kgCfS2nlgOkLMkQX5COyzXviIXW1
>oFwAoKe2K0ceu6Vw+XiMpGCORYD55x3u
>=IqxP
>-----END PGP SIGNATURE-----
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message