Kumar,
I've been trying to follow the JDBC pb thread as well and still can't
get rid of the
problem. Here is what I've done.
Using J Connector 3.0, Tomcat 4.1.30 and mySQL 4.0.18.
I put my "mysql-connector-java-3.0.11-bin" under /common/lib.
1. Start from simple web.xml:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/mySQLDatabase</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
2. server.xml (located at $CATALINA_HOME\conf\server.xml)
<Context path="/db" docBase ="ROOT" debug="9" reloadable="true">
<Resource name="jdbc/mySQLDatabase" auth="Shareable"
type="javax.sql.DataSource" description="JDBC Connection to
MySQL v4.0.18"/>
<ResourceParams name="jdbc/mySQLDatabase">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>serverName</name>
<value>localhost</value>
</parameter>
<parameter>
<name>databaseName</name>
<value>ecpa</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
<parameter>
<name>username</name>
<value>xxxx</value>
</parameter>
<parameter>
<name>password</name>
<value>xxxx</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>200</value>
</parameter>
<parameter>
<name>logAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/ecpa?autoReconnect=true</value>
</parameter>
</ResourceParams>
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="DBlog." suffix=".txt"
timestamp="true"/>
</Context>
3. In my code:
Context ctx = new InitialContext();
if(ctx == null)
{
throw new Exception("\nNo Context Error");
}
DataSource ds = (DataSource)
ctx.lookup("java:comp/env/jdbc/mySQLDatabase");
if (ds == null)
{
System.out.println("\n DataSource is NULL ");
}
Connection conn = ds.getConnection();
if (conn != null)
{
System.out.println("\nGot Connection ");
Statement stmt = conn.createStatement();
ResultSet rst =
stmt.executeQuery("select username from
users");
if(rst.next())
{
System.out.println("\n username: " +
rst.getString(1));
}
conn.close();
}
4. Error message I got from printStackTrace():
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver
of class '
' for connect URL 'null', cause:
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:243)
at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
rce.java:743)
at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
.java:518)
at
com.maxis.app.ContentProcessor.initializeDatabase(ContentProcessor.ja
va:60)
at com.maxis.morequest.DBTest.init(DBTest.java:31)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:935)
at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.jav
a:668)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:210)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
I believe these are the steps everybody else implementing, but I still
get this
error... Did I miss something?
Thanks,
--Kawthar
Confidential information may be contained in this e-mail and any files transmitted
with it ('Message'). If you are not the addressee indicated in this Message (or
responsible for delivery of this Message to such person), you are hereby notified that
any dissemination, distribution, printing or copying of this Message or any part
thereof is strictly prohibited. In such a case, you should delete this Message
immediately and advise the sender by return e-mail. Opinions, conclusions and other
information in this Message that do not relate to the official business of Maxis shall
be understood as neither given nor endorsed by Maxis.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]