tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From echam...@TXU.COM
Subject Re: Cannot load JDBC driver class 'null'
Date Thu, 10 Oct 2002 12:43:35 GMT


If you are going to use the Global Resources, there are a few changes I
have noted with
the Tomcat 4.1.x.

  You no longer have to  put a ResourceRef tag in the web.xml file
  You need to put a ResourceLink tag within the Context tag of the
application in the server.xml.

Also, if you are putting the database resources in the global resources,
you do not need
to identify the factory to use since Tomcat will automatically default to
the Apache
Commons DBCP.

If you place the databse resource inside the context definition, then you
will have to
define the factory to use if you want DBCP and will have to place a
ResourceRef Tag
in the web.xml

Hope this helps,

Ulrik Andersen <> on 10/10/2002 06:37:39 AM

Please respond to "Tomcat Users List" <>

To:    "''" <>

Subject:    Cannot load JDBC driver class 'null'


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
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: <>

Confidentiality Notice: This email message, including any attachments,
contains or may contain confidential information intended only for the 
addressee.  If you are not an intended recipient of this message, be 
advised that any reading, dissemination, forwarding, printing, copying 
or other use of this message or its attachments is strictly prohibited.  
If you have received this message in error, please notify the sender 
immediately by reply message and delete this email message and any 
attachments from your system. 

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

View raw message