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

Ulrik:

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




Ulrik Andersen <ulrik.andersen@softdesign.dk> on 10/10/2002 06:37:39 AM

Please respond to "Tomcat Users List" <tomcat-user@jakarta.apache.org>

To:    "'tomcat-user@jakarta.apache.org'" <tomcat-user@jakarta.apache.org>
cc:

Subject:    Cannot load JDBC driver class 'null'


Hi,

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">
...
  <GlobalNamingResources>
...
    <Resource auth="Container" name="jdbc/WebsydianTest"
type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/WebsydianTest">
      <parameter>
        <name>factory</name>
        <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
      </parameter>
      <parameter>
        <name>driverClassName</name>
        <value>sun.jdbc.odbc.JdbcOdbcDriver</value>
      </parameter>
      <parameter>
        <name>url</name>
        <value>jdbc:odbc:Websydiantest</value>
      </parameter>
      <parameter>
        <name>validationQuery</name>
        <value>select * from AA1T</value>
      </parameter>
      <parameter>
        <name>maxIdle</name>
        <value>2</value>
      </parameter>
      <parameter>
        <name>maxActive</name>
        <value>10</value>
      </parameter>
      <parameter>
        <name>maxWait</name>
        <value>5000</value>
      </parameter>
      <parameter>
        <name>user</name>
        <value>dba</value>
      </parameter>
      <parameter>
        <name>username</name>
        <value>dba</value>
      </parameter>
      <parameter>
        <name>password</name>
        <value>sql</value>
      </parameter>
    </ResourceParams>
  </GlobalNamingResources>
...
</server>


My web-inf/web.xml file looks like this:
<web-app>
...
  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/WebsydianTest</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>
</web-app>

Any help will be appreciated.
Ulrik

--
To unsubscribe, e-mail:   <
mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <
mailto:tomcat-user-help@jakarta.apache.org>









**********************************************************************************
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:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message