Your setup is textbook for tomcat 4.1.x, but I took a quick look at the docs for 4.0 and things look very slightly different. Take a look at:

http://tomcat.apache.org/tomcat-4.0-doc/jndi-resources-howto.html

One thing I'm wondering considering the docs for 4.0 don't mention the DBCP pooling is where you put dbcp.jar. It'll have to be in common/lib right next to the hsqldb.jar.

--David

Roy Kiesler wrote:

I have been trying for 2 days now to setup a simple connection pool in
Tomcat 4.0.6 for a Hypersonic database with the ever-so-popular error in the
subject. I have read every possible Google post on the subject, but found
not solution for Tomcat 4, only 5.x.

Anyhow, here's the setup:


  1. hsqldb.jar is placed in %CATALINA_HOME%/common/lib
  2. %CATALINA_HOME%/server/conf/server.xml contains the following
  context definition:

  <Context path="/BookmartDB"
           docBase="BookmartDB"
           debug="5"
           reloadable="true"
           crossContext="true">

     <Logger className="org.apache.catalina.logger.FileLogger"
             prefix="localhost_BookmartDB_log."
             suffix=".txt"
             timestamp="true"/>

     <Resource name="jdbc/BookmartDB"
               auth="Container"
               type="javax.sql.DataSource"/>

     <ResourceParams name="jdbc/BookmartDB">
        <parameter>
           <name>factory</name>
           <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
        </parameter>

        <parameter>
           <name>maxActive</name>
           <value>100</value>
        </parameter>

        <parameter>
           <name>maxIdle</name>
           <value>30</value>
        </parameter>

        <parameter>
           <name>maxWait</name>
           <value>10000</value>
        </parameter>

        <parameter>
           <name>username</name>
           <value>sa</value>
        </parameter>

        <parameter>
           <name>password</name>
           <value></value>
        </parameter>

        <parameter>
           <name>driverClassName</name>
           <value>org.hsqldb.jdbcDriver</value>
        </parameter>

        <parameter>
           <name>url</name>
           <value>jdbc:hsqldb:file:c:/bookmart</value>
        </parameter>

        <parameter>
           <name>removeAbandoned</name>
           <value>true</value>
        </parameter>

        <parameter>
           <name>removeAbandonedTimeout</name>
           <value>60</value>
        </parameter>

        <parameter>
           <name>logAbandoned</name>
           <value>true</value>
        </parameter>

     </ResourceParams>
  </Context>

  3. %CATALINA_HOME%/server/webapps/bookmartClient/WEB-INF/web.xml
  contains the following resource reference:

  <resource-ref>
     <description>DB Connection</description>
     <res-ref-name>jdbc/BookmartDB</res-ref-name>
     <res-type>javax.sql.DataSource</res-type>
     <res-auth>Container</res-auth>
  </resource-ref>

  4. My JSP code contains the following:

  Context initCtx = new InitialContext();
  Context envCtx = (Context) initCtx.lookup("java:comp/env");
  DataSource ds = (DataSource)envCtx.lookup("jdbc/BookmartDB");
  Connection conn = ds.getConnection();

This does not appear to be an issue with the driver, as the following code
works just fine:

Class.forName("org.hsqldb.jdbcDriver" );
Connection conn = DriverManager.getConnection("jdbc:hsqldb:file:c:/bookmart",
"sa", "");
Statement stmt = conn.createStatement();
ResultSet rst = stmt.executeQuery("select * from testdata");
if (rst.next())
{
  foo = rst.getString(2);
  bar = rst.getInt(3);
}

Hopefully this paints the picture clearly enough. Any insights?

Thanks,
--
Roy



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to