tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ulrik Andersen <>
Subject Cannot load JDBC driver class 'null'
Date Thu, 10 Oct 2002 11:37:39 GMT

I am using Tomcat 4.1.12 and trying to use the JNDI service to get a
database connection.

My code looks like this:
      Context ctx = new InitialContext();
      Object o = ctx.lookup("java:comp/env/jdbc/WebsydianTest");
      DataSource ds = (DataSource) o;
      Connection conn = ds.getConnection();

The last statement results in the following exception:
java.sql.SQLException: Cannot load JDBC driver class 'null'

Having debugged a little bit I have found out that it seems that the
returned DataSource object is not initialized with any of the parameters in
the server.xml file. I used the following code to verify this:
     org.apache.commons.dbcp.BasicDataSource bds =
                (org.apache.commons.dbcp.BasicDataSource) ds;
     out.println("<p>Max active: " + bds.getMaxActive() + "</p>");
     out.println("<p>Max idle: " + bds.getMaxIdle() + "</p>");
     out.println("<p>Max wait: " + bds.getMaxWait() + "</p>");
     out.println("<p>User: " + bds.getUsername() + "</p>");
     out.println("<p>Password: " + bds.getPassword() + "</p>");

What am I doing wrong? I have searched the archive and I can see that I am
not the only one getting this error message, but none of the solutions seems
to have something to do with that the parameters are not loaded from the
server.xml file.

My server.xml file looks like this:
<Server className="org.apache.catalina.core.StandardServer" debug="0"
port="8005" shutdown="SHUTDOWN">
    <Resource auth="Container" name="jdbc/WebsydianTest"
    <ResourceParams name="jdbc/WebsydianTest">
        <value>select * from AA1T</value>

My web-inf/web.xml file looks like this:
      <description>DB Connection</description>

Any help will be appreciated.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message