Tomcat JNDI DataSource issues
Hello, I have followed the Book to the letter and I am getting a " Cannot create PoolableConnectionFactory" error when I run the JDBCTest.jsp.Based on what I am seeing it is when the connection in the jsp file is attempted. What am I doing wrong.I tested the Mysql empro user with the MySql client tools and it was able to get data.
I have RedHat 9.0
Tomcat 4.1.29
SunJava 1.4.1_06
MySQL 3.23.54
MySqlJConnector mysql-connector-java-3.0.9-stable in the <Tomcat_Home>/common/lib and Shared/lib
The dbcp,pool, and collection JARs are where they are supposed to be.
server.xml I had them in neater but the Admin tool rearanged it;
The Admin Tool did see the DefaultContext tags
<DefaultContext className="org.apache.catalina.core.StandardDefaul tContext" cookies="true" crossContext="true" name="defaultContext" reloadable="false" swallowOutput="false" useNaming="true" wrapperClass="org.apache.catalina.core.StandardWra pper">
<Resource auth="Container" name="jdbc/WroxTC41" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/WroxTC41">
<parameter>
<name>maxWait</name>
<value>100</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>password</name>
<value>empass</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/wroxtomcat</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30000</value>
</parameter>
<parameter>
<name>username</name>
<value>empro</value>
</parameter>
<parameter>
<name>debug</name>
<value>0</value>
</parameter>
</ResourceParams>
</DefaultContext>
web.xml
<resource-ref>
<res-ref-name>jdbc/WroxTC41</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
I put part of the JDBCTest.jsp together looking for the fault
<HTML>
<HEAD>
<%@ page errorPage="errorpg.jsp"
import="java.sql.*,
javax.sql.*,
java.io.*,
javax.naming.InitialContext" %>
</HEAD>
<BODY>
<H1>JDBC JNDI Resources Test</H1>
<%
InitialContext initCtx = new InitialContext();
DataSource ds = (DataSource)initCtx.lookup("java:comp/env/jdbc/WroxTC41");
Connection conn = ds.getConnection();
conn.close();
initCtx.close();
%>
</Body>
</HTML>
|