Like thousands beforefore, I can't get connection pooling to work in Tomcat. I followed all the steps:
- put jar file for MySQL JDBC driver in TOMCAT_HOME/common/lib
- put the Jakarta Commons libs in the same location
- put resource declaration in META-INF/context.xml, per the Tomcat 5.5 docs like so:
<Context docbase="C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\commutercorps"
path="\commutercorps" >
<Resource name="jdbc/commutercorpsds"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="myusername"
password="mypassword"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/commuter_corps_signup"/>
</Context>
- added resource ref in web.xml
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/commutercorpsds</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
I also double checked my connection URL and found that it
does work fine when do this in my Java code:
Class.forName("com.mysql.jdbc.Driver");
Connection con =
DriverManager.getConnection
("jdbc:mysql://localhost:3306/commuter_corps_signup", "...", "...");
When I try to use Tomcat 5.5.4, JNDI like this...
try
{
InitialContext initialContext = new InitialContext();
DataSource dataSource =
(DataSource) initialContext.lookup
("java:comp/env/jdbc/commutercorpsds");
Connection con = dataSource.getConnection();
Statement stmt = con.createStatement();
stmt.executeUpdate(SQLMaker.getInsert(request,
request.getParameter("table")));
con.close();
stmt.close();
} catch (NamingException e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
...I get...
Cannot create JDBC driver of class '' for connect URL 'null'
...
Caused by: java.sql.SQLException: No suitable driver
Any help would be greatly appreciated.
Thanks,
E