tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ross Fujii" <>
Subject Tomcat 4.0.2 - MySQL Connection Pooling
Date Fri, 22 Feb 2002 22:14:05 GMT

I'm trying to setup JNDI connection pooling in Tomcat 4.0.2
to a MySQL (v3.23.49) database.  I'm also running an Apache
1.3.20 AJP13 connector (using mod_jk) if that makes a difference
all on a RedHat Linux 7.2 server.

The following is a snippet of the JNDI resource creation
in server.xml:

    <Host name="" debug="0" appBase="webapps/" 
        <Context path="/test" docBase="test" debug="1"
                 reloadable="true" privileged="true">
          <Resource name="jdbc/TestDB" auth="Container"
          <ResourceParams name="jdbc/TestDB">

The following is the corresponding web.xml:

The sample code that I'm using in a servlet to grab the connection
is the following:
       //Get the pooled DB connection
       Context initCtx = new InitialContext();
       Context envCtx = (Context)initCtx.lookup("java:comp/env");
       DataSource ds = (DataSource)envCtx.lookup("jdbc/TestDB");

       //Connect to the DB data source and run a query

The exception that is being thrown is:

       javax.naming.NamingException: Cannot create resource instance

I was wondering if there is somemthing that I'm still missing???

Some other notes:
-- Have setup connection pooling to SQL 2000 DB on Windows 2000
   using Tomcat 4.0.2b1 with no problem.
-- Have coded a stand-alone application that works and is able
   to connect to MySQL and query the DB with no problems
-- Have upgraded to the latest MySQL 2.0.11 driver

Any help or advice would be greatly appreciated.
Thanks in advance,

MSN Photos is the easiest way to share and print your photos:

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message