Tomcat 5.09 MySQL Driver 3.08 stable OS: Mac OSX 10.2.6 J2SE 1.4.2
all commons libraries reside in $CATALINA_HOME/common/lib MySQL Driver resides in $CATALINA_HOME/common/lib as well
I tried setting up a simple JNDI datasource connection but get the following error message:
java.sql.SQLException: Cannot load JDBC driver class 'null'
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource .java:529)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.ja va:312)
at foo.DBTest.init(DBTest.java:24)
at foo.TestServlet.doGet(TestServlet.java:34)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
....
....
The code and examples are taken from http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource- examples-howto.html
I have searched through tons of archives and websites and mostly this error could be resolved by placing the driver and commons in the common/lib directory. However in my case they are there, so I cannot figure out what's the problem...
server.xml:
<Context path="/DBTest" docBase="DBTest" debug="5"
reloadable="true" crossContext="true"><Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_DBTest_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/><ResourceParams name="jdbc/TestDB"> <parameter> <name>driverClassName</name> <value>org.gjt.mm.mysql.Driver</value> </parameter> <parameter> <name>username</name> <value>xxx</value> </parameter> <parameter> <name>password</name> <value>xxx</value> </parameter> <parameter> <name>url</name> <value>jdbc:mysql://localhost/javatest?autoReconnect=true</value> </parameter> </ResourceParams> </Context>
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<description>MySQL Test App</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref> <servlet>
<servlet-name>DBTestServlet</servlet-name>
<description>
Bla...
</description>
<servlet-class>foo.TestServlet</servlet-class>
</servlet> <servlet-mapping>
<servlet-name>DBTestServlet</servlet-name>
<url-pattern>/DBTestServlet</url-pattern>
</servlet-mapping>
</web-app>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
