Dear All:

I have read numerous posts and documentation and now I really need help.


I am using the following:

Product Version: NetBeans IDE 7.0 (Build 201104080000)
Java: 1.6.0_26; Java HotSpot(TM) Client VM 20.1-b02
System: Windows 7 version 6.1 running on x86; 
Apache Tomcat 6.0.26
MySQL Version: 5.5.14
MySQL Connector/J JDBC Driver 5.1.17


I performed the steps below as follows:

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) 
<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>
</CODE>

I have modified the XML file (META-INF/context.xml) found in the project’s 
folders
<CODE>
<?xml version="1.0" encoding="UTF-8"?>
<Context crossContext="true" debug="5" docBase="TweetCollector" 
antiJARLocking="true" path="/TweetCollector"
 reloadable="true">  
    <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"/>
</Context>
</CODE>

I have modified the code in the java class for the database
 connection
<CODE>
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)
  envCtx.lookup("jdbc/myDB");

setConnectionDB(ds.getConnection());
</CODE>

I
 read the steps at 
http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#JDBC_Data_Sources.
 I have also tried modifying the server.xml file. 

The connection in the log prints as
jdbc:mysql://localhost:3306/myDB?autoReconnect=true, UserName=root@localhost, 
MySQL-AB JDBC Driver

However, it gives the error:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver
OR
java.sql.SQLException: No suitable driver

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.

Cheers

Reply via email to