Discussion:
Cannot load JDBC Driver class com.ibm.db2.jdbc.app.DB2Driver
Stephen Peterson
2003-04-02 10:28:16 UTC
Permalink
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
g***@bcn.concatel.com
2003-04-03 09:37:49 UTC
Permalink
try using the com.ibm.db2.jdbc.net.DB2Driver . (instead of the
...app.DB2Driver.)
it's a thin client that doesn't require finding libraries locally...
url would be something like:
jdbc:db2//localhost/db_name

or if you use a non-standard port and use an ip address instead of a
hostname:
jdbc:db2//192.168.1.123:9993/db_name

/gilad



Gilad Buzi
R&D Engineer · CONCATEL


***@bcn.concatel.com
c/Sardenya, 229-237 Atic. 2a ·
08013 Barcelona Spain
tel. +34.93.244.88.77 · fax
+34.93.244.88.78

www.concatel.com







Stephen
Peterson Para: tomcat-***@jakarta.apache.org
<***@yah cc:
oo.com> Asunto: Cannot load JDBC Driver class com.ibm.db2.jdbc.app.DB2Driver

02/04/2003
12:28
Por favor,
responda a
"Tomcat Users
List"





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-***@jakarta.apache.org
For additional commands, e-mail: tomcat-user-***@jakarta.apache.org
Darian Shimy
2003-04-03 17:55:54 UTC
Permalink
I never had too much success with the net driver. But I think your problem
is with the class name. The name of the class is
COM.ibm.db2.jdbc.net.DB2Driver. Note the COM in all caps.

--
Darian Shimy
-----Original Message-----
Sent: Thursday, April 03, 2003 1:38 AM
To: Tomcat Users List
Subject: Re: Cannot load JDBC Driver class
com.ibm.db2.jdbc.app.DB2Driver
try using the com.ibm.db2.jdbc.net.DB2Driver . (instead of the
...app.DB2Driver.)
it's a thin client that doesn't require finding libraries locally...
jdbc:db2//localhost/db_name
or if you use a non-standard port and use an ip address instead of a
jdbc:db2//192.168.1.123:9993/db_name
/gilad
Gilad Buzi
R&D Engineer * CONCATEL
c/Sardenya, 229-237 Atic. 2a *
08013 Barcelona Spain
tel. +34.93.244.88.77 * fax
+34.93.244.88.78
www.concatel.com
Stephen
oo.com> Asunto: Cannot
load JDBC Driver class com.ibm.db2.jdbc.app.DB2Driver
02/04/2003
12:28
Por favor,
responda a
"Tomcat Users
List"
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.
==============
<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>
================
<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>
===================
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();
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.
----------------
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
---------------------------------------------------------------------
---------------------------------------------------------------------
p***@aurora.org
2003-04-03 18:12:04 UTC
Permalink
I have it running with the net driver. I could not get eh JNDI lookup to
run with the app dirver. Are you connecting to a remote db??

Paul R. Johnson




Darian Shimy
<***@24hourfit To: 'Tomcat Users List' <tomcat-***@jakarta.apache.org>
.com> cc:
Subject: RE: Cannot load JDBC Driver class com.ibm.db2.jdbc.app.DB2Driver
04/03/2003 11:55
AM
Please respond to
"Tomcat Users
List"






I never had too much success with the net driver. But I think your problem
is with the class name. The name of the class is
COM.ibm.db2.jdbc.net.DB2Driver. Note the COM in all caps.

--
Darian Shimy
-----Original Message-----
Sent: Thursday, April 03, 2003 1:38 AM
To: Tomcat Users List
Subject: Re: Cannot load JDBC Driver class
com.ibm.db2.jdbc.app.DB2Driver
try using the com.ibm.db2.jdbc.net.DB2Driver . (instead of the
...app.DB2Driver.)
it's a thin client that doesn't require finding libraries locally...
jdbc:db2//localhost/db_name
or if you use a non-standard port and use an ip address instead of a
jdbc:db2//192.168.1.123:9993/db_name
/gilad
Gilad Buzi
R&D Engineer * CONCATEL
c/Sardenya, 229-237 Atic. 2a *
08013 Barcelona Spain
tel. +34.93.244.88.77 * fax
+34.93.244.88.78
www.concatel.com
Stephen
oo.com> Asunto: Cannot
load JDBC Driver class com.ibm.db2.jdbc.app.DB2Driver
02/04/2003
12:28
Por favor,
responda a
"Tomcat Users
List"
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.
==============
<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>
================
<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>
===================
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();
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.
----------------
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
---------------------------------------------------------------------
---------------------------------------------------------------------
Stephen Peterson
2003-04-06 13:25:47 UTC
Permalink
Thanks for everyone's responses.

Darian Shimy's comment
Post by Darian Shimy
COM.ibm.db2.jdbc.net.DB2Driver. Note the COM in all caps.
was the root problem - after I fixed this, things worked much
better! The next problem I received, I think was alluded to
by the first reply by Fabio Mengue that the user and pw
parameters must be specified in the xml. The java stmt
Connection conn = ds.getConnection("user","pw");

triggers this problem:
java.lang.UnsupportedOperationException
at
org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:125)
at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:329)

The Websphere datasource can take a userid and password argument
on getConnection. I use this
to authenticate with the login screen on the AIX server, so with
Tomcat maybe I'll have to
do this connection without pooling - the pooling probably
doesn't help much with overhead anyway
for this situation.

Some other points suggested in the responses:

- The url value is typically all lower case in IBM/websphere
examples and that is what worked

- in windows, I took out all modifications to setclasspath.bat,
and it worked fine - the extension was .bat, not .sh as I
incorrectly wrote. It also worked fine starting as a service
instead of using startup.bat, although I don't seem to get
stdout appearing anywhere as I do when using startup.sh. The
logs directory is empty.

- regarding the db2profile question I had earlier, I think that
was all a non-issue on Windows. The IBM DB2 client software
'catalogues' a database name on the pc, which the db2 driver
seems to be able to connect to without any other additional
configuration efforts.

- regarding the net driver - yes I used that several years ago
when I had built an applet. I have read in IBM news groups that
the net driver is much less efficient than the app driver and so
the app driver is always preferred when using websphere, or, I
would speculate, any other app server.




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

Continue reading on narkive:
Loading...