Hello all,
I've harranged over this way too long! It looks so easy to use, but I can't
figure it out.
I can't connect to mysql using the JNDI DB Datasource from Tomcat 4.03.
Error "Null Pointer" occurs whenever I call the connection in my JSP:
Connection myConn = ds.getConnection();
Two notes:
1. I get a connection, when I define it explicitly inside the JSP.
EG: Class.for.... Connection myConn = DriverManager.getConnection...
Using JNDI fails....
2. I tried the same parameters in the server.xml to both my webapp
context and the host section, hoping it would work... no good.
I've included the relevent parts of server.xml, web.xml, and the JSP.
Any and all help is appreciated!
--John
------------------------------------------------------------
server.xml (from my "test" context)
<Resource name="jdbc/testDB" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/testDB">
<parameter><name>user</name><value>someone</value></parameter>
<parameter><name>password</name><value>aguess</value></parameter>
<parameter><name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value></parameter>
<parameter><name>driverName</name>
<value>jdbc:mysql://127.0.0.1/test</value></parameter>
</ResourceParams>
------------------------------------------------------------
web.xml
<resource-ref>
<description>
Resource reference to a factory for java.sql.Connection
instances that may be used for talking to a particular
database that is configured in the server.xml file.
</description>
<res-ref-name>
jdbc/testDB
</res-ref-name>
<res-type>
javax.sql.DataSource
</res-type>
<res-auth>
Container
</res-auth>
</resource-ref>
----------------------------------------------------------
test.jsp
<%
Context initCtx=new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
DataSource ds= (DataSource) envCtx.lookup("jdbc/testDB");
/* Connection myConn = ds.getConnection();
NULL Pointer occurs when uncommented....
*/
%>
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>