Hi folks. Any help with this problem would be greatly appreciated. I'm
trying to set up Tomcat 5.5 to provide a JNDI DataSource of a MySQL
4.0.22 server on Windows XP. Configuration details are below. When I
step through the code in the debugger, it appears that the DataSource
object is sucessfully created. At least it isn't null. However, when
it gets to the line...
Connection con = dataSource.getConnection();
... it throws this exception:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC
driver of class '' for connect URL 'null'
at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at gov.mtc.webproc.RequestManager.doPost(RequestManager.java:65)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
etc...
------------------------------------------------------------------
Some more details:
- I put the driver (mysql-connector-java-3.1.6-bin.jar) into
TOMCAT_HOME/common/lib/.
- In server.xml, inside <Host name="localhost" ... > ... </Host> I put
this configuration:
<DefaultContext>
<Resource name="jdbc/commutercorpsds" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/commutercorpsds">
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/commuter_corps_signup</value>
</parameter>
<parameter>
<name>username</name>
<value>USERNAME</value>
</parameter>
<parameter>
<name>password</name>
<value>PASSWORD</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30000</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>100</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>15</value>
</parameter>
</ResourceParams>
</DefaultContext>
- In my application's web.xml I put this:
<resource-ref>
<res-ref-name>jdbc/commutercorpsds</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
- In my Java code I put this:
try
{
InitialContext initialContext = new
InitialContext();
DataSource dataSource =
(DataSource) initialContext.lookup
("java:comp/env/jdbc/commutercorpsds");
Connection con = dataSource.getConnection();
Statement stmt = con.createStatement();
...
con.close();
stmt.close();
} catch (NamingException e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
Andreas Wollschlaeger - 29 Jan 2005 21:51 GMT
> Hi folks. Any help with this problem would be greatly appreciated. I'm
> trying to set up Tomcat 5.5 to provide a JNDI DataSource of a MySQL
[quoted text clipped - 53 lines]
> </ResourceParams>
> </DefaultContext>
I remember i had this kind of problem with Tomcat 4.0.6 some decade ago
- try moving the configuration of the Datasource from the DefaultContext
to a more specific context. Some neurons say this was a problem with
Tomcat 4, so i'm surprised this still happens with Tomcat 5.5 - as the
DefaultContext is the most natural place. Maybe have a look
jakarta.apache.org, i think it was somewhere in the FAQs.
HTH, though :-)
Andreas
elektrophyte - 30 Jan 2005 05:30 GMT
Thanks for the reply. I tried adding the DataSource config to an
application-specific context, but the result was the same.
Daniel Rohe - 30 Jan 2005 07:41 GMT
The configuration of a resource has changed from tomcat 5.0 to 5.5, so
please read the docs
greetings
Daniel
> Hi folks. Any help with this problem would be greatly appreciated. I'm
> trying to set up Tomcat 5.5 to provide a JNDI DataSource of a MySQL
[quoted text clipped - 102 lines]
> e.printStackTrace();
> }