Take a look at my long spiel about the same problem; it should be in the
list archive from a day or two ago.
What I'd do first is this:
1. Make sure that the servlet doing the lookup is in the context you think
it's in.
2. Make sure you can connect to the database using a short jdbc program
using the same parameters you're using here.
On Tue, 23 Apr 2002, Vincent Lambert wrote:
> I am trying to use database connection pooling with Tomcat 4.0.3 through
> JNDI (jdk 1.4).
> I am using MySQL database with mm.mysql driver v 2.0.12.
>
> Context initCtx = new InitialContext();
> Context envCtx = (Context) initCtx.lookup("java:comp/env");
> DataSource w_ds = (DataSource) envCtx.lookup("jdbc/ds");
>
> With this code inserted into a servlet or a JSP, I am getting a NULL
> DataSource !
>
>
> Here is a piece of my configuration files:
> server.xml:
> <Resource name="jdbc/ds" auth="Container" type="javax.sql.DataSource"/>
> <ResourceParams name="jdbc/ds">
> <parameter>
> <name>driverClassName</name>
> <value>org.gjt.mm.mysql.Driver</value>
> </parameter>
> <parameter>
> <name>driverName</name>
> <value>jdbc:mysql://localhost/test</value>
> </parameter>
> <parameter>
> <name>user</name>
> <value>youruser</value>
> </parameter>
> <parameter>
> <name>password</name>
> <value>yourpasswd</value>
> </parameter>
> </ResourceParams>
>
> web.xml:
> <resource-ref>
> <description>
> Resource reference to a factory for javax.sql.Datasource
> </description>
> <res-ref-name>jdbc/ds</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
>
> Thanks for help...
>
> Regards,
> Vincent
>
--
"The aptly-named morons.org is an obscenity-laced screed..."
-- Robert P. Lockwood, Catholic League director of research
Nick Johnson, version 2.0 http://www.spatula.net/
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>