tomcat-users mailing list archives

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

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="www.abc.com" debug="0" appBase="webapps/abc.com" 
unpackWARs="true">
        <Context path="/test" docBase="test" debug="1"
                 reloadable="true" privileged="true">
          <Resource name="jdbc/TestDB" auth="Container"
                    type="javax.sql.DataSource"/>
          <ResourceParams name="jdbc/TestDB">
            <parameter><name>user</name><value>root</value></parameter>
   <parameter><name>password</name><value>aseraser</value></parameter>
            <parameter>
              <name>driverClassName</name>
              <value>org.gjt.mm.mysql.Driver</value>
            </parameter>
            <parameter>
              <name>driverName</name>
              <value>jdbc:mysql://localhost/menagerie</value>
            </parameter>
          </ResourceParams>

The following is the corresponding web.xml:
       <resource-ref>
           <res-ref-name>jdbc/TestDB</res-ref-name>
           <res-type>javax.sql.DataSource</res-type>
           <res-auth>Container</res-auth>
       </resource-ref>

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,
--Ross


_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message