You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Stephen Peterson <cs...@yahoo.com> on 2003/04/02 12:28:16 UTC

Cannot load JDBC Driver class com.ibm.db2.jdbc.app.DB2Driver

Hello,

I'm getting this java.sql.SQLException when trying to open a
connection
on my datasource.  The WebSphere Test Environment datasource
opens connections fine,
but not Tomcat/4.1.24.  Other details, using DB2 Personal
Edition version 7.2,
on Windows 2000 Professional.

I copied C:\sqllib\db2java.zip to $CATALINA_HOME/common/lib
directory, renaming
to db2java.jar.

I verified that the com.ibm.db2.jdbc.app.DB2Driver class was
actually in the jar file.

In the server.xml listing below I added parms for username
and password since I always see them in other postings, although
I have always spcified the username/password in the
getConnection
method call, successfully in websphere.
==============
server.xml:

<DefaultContext>
  <Resource name="jdbc/GuppyDB" auth="Container"
            type="javax.sql.DataSource"/>
  <ResourceParams name="jdbc/GuppyDB">
    <parameter>
      <name>factory</name>
     
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
      <name>driverClassName</name>
      <value>COM.ibm.db2.jdbc.app.DB2Driver</value>
    </parameter>
    <parameter>
      <name>url</name>
      <value>jdbc:db2:gupt1b</value>
    </parameter>
    <parameter>
      <name>password</name>
      <value>password</value>
    </parameter>
    <parameter>
      <name>username</name>
      <value>user1</value>
    </parameter>
    <parameter>
      <name>maxActive</name>
      <value>8</value>
    </parameter>
    <parameter>
      <name>maxIdle</name>
      <value>4</value>
    </parameter>
  </ResourceParams>
</DefaultContext>
================
in web.xml:
<resource-ref>
  <description>
    Resource reference to a factory for java.sql.Connection
    instances that may be used for talking to a particular
    database that is configured in the server.xml file.
  </description>
  <res-ref-name>
    jdbc/GuppyDB
  </res-ref-name>
  <res-type>
    javax.sql.DataSource
  </res-type>
  <res-auth>
    Container
  </res-auth>
</resource-ref>
===================
in my servlet:

import java.sql.Connection;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/GuppyDB");
Connection conn = ds.getConnection("user1", "passwd");
conn.close();

The following is thrown in the ds.getConnection method:

java.sql.SQLException: Cannot load JDBC driver class
'com.ibm.db2.jdbc.app.DB2Driver'

Now I did see Fabio Mengue's posting from Feb 20 in a response
to someone asking a similar question.  I compared his config
with mine, added at the top of <TOMCAT>/bin/setclasspath.sh
the line
set JAVA_OPTS="-Djava.library.path=C:/Program
Files/sqllib/java/"

and started tomcat with the startup.sh instead of the services
start in the Computer Management dialog.

The other item:
----------------
Add the following line
Create <TOMCAT>/bin/setenv.sh, as a copy (or a link) of file
<DB2>/sqllib/db2profile.
----------------
I am at a loss, since I cannot find a db2profile file on my PC,
although I do have the DB2 server software installed as well as
the 
DB2 client software.

If anyone has any helpful suggestions that would be welcome.

Thanks
Stephen Peterson

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com

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