*
The moose likes Websphere and the fly likes Help on DB2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Help on DB2" Watch "Help on DB2" New topic
Author

Help on DB2

Girish SV
Greenhorn

Joined: Jan 17, 2001
Posts: 14
I am working on DB2 6.1 with WebSphere 3.5
1)My servlet(on websphere) is able to connect to DB2 on the same machine even without any classpath settings done eihter in MyComputer >> Environment(in Windows NT machine) OR in Websphere Admin console.How is this ??
2)As a next step, i want my servlet to connect to DB2 on a different machine (in LAN).
I have mapped the drive containing DB2 drivers in my servlets machine and set the classpath to it.
My classpath is D:\SQLLIB\java\Db2java\COM\ibm\db2\jdbc\net\DB2Driver.class
the jdbc connection string is as follows :
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
con = DriverManager.getConnection("jdbc:db2:test","wasad","wasadmin");
With this i am getting the error "unable to load driver"
Pls. help me with this,
Girish.
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1844
Hi,
Extract the jar file for the driver and see whether the COM.ibm.db2.jdbc.net.DB2Driver Directory structure exists in the Driver jar file. I think it should be "com.ibm." as the package names are always in lower case.
Also check out whether it should be
"com.ibm.db2.jdbc.app.DB2Driver"
and not what you have stated.

------------------

Mahindrakar
IBM Application Server Forum Moderator
SCJP
Girish SV
Greenhorn

Joined: Jan 17, 2001
Posts: 14
I have no jar files here but i have db2java.zip under d:\sqllib\java\ which i extracted . this extracted folder contains the folder strucure Com\ibm\db2\jdbc folders ..under this jdbc folder there are folders app and net which each contain 'DB2Driver.class' file.So i am setting the classpath to this.
For remote connectivity does running of all Db2 services is enough or is there any other tool to be running..like gateways or some thing necessary for remote connectivity..
thanks,
Girish
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1844
I guess you have set the path to db2java.zip and not the class file by unziping it.
I have unziped my db2java.zip file and find in it tow DB2Driver.class files
The first one belongs to the "COM.ibm.db2.jdbc.app"
and the second one belongs to "COM.ibm.db2.jdbc.net" packages
I use the first one on my system as i could specify only that in my Websphere application server when configuring the driver.
Also it is strange that IBM uses the "COM" all in caps as packages are supposed to be in lowercase.
Please look at package names or write them carefully whenever you do so.
Why dont you try to change the HitCounterBean's DataSource to your DB2 database and restart the server. If you get any specific errors then we can look into it.
Hope we get it right this time

------------------

Mahindrakar
IBM Application Server Forum Moderator
SCJP

[This message has been edited by Rahul Mahindrakar (edited April 27, 2001).]
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1844
Hi,
I tried configuring WAS for DB2 and found that it is not working on his system giving the could not find JDBC driver class exception the same as yours.
I have DB2 on my system that also has WAS. when i load the driver on my system things work fine. Even the beans etc work fine.
I have a doubt as to where do i specify the system where the DB2 is running for example in oracle you would specify it in the URL by saying
jdbc : oracle:thin@localhost:1521
in DB2 however you only say
jdbc:db2
so where do we specify @localhost in db2 ???
Anything i am missing??
By the way girish you have to have the driver in your classpath. just check if you have to change one of the properties file in websphere or add it in the console window. I think the name of the file is bin\admin.config and the line to which you have to add your classpath is
com.ibm.ejs.sm.adminserver.classpath
I hope this works for you.
------------------

Mahindrakar
IBM Application Server Forum Moderator
SCJP

[This message has been edited by Rahul Mahindrakar (edited April 27, 2001).]
cs_cty
Greenhorn

Joined: May 02, 2001
Posts: 1
Hi,
I follow your description and unzip the db2java.zip file to a directory, let say "test". and then i set the classpath to the directory, it doesn't work, then i reset the classpath to the directory contains the two class files and run the program in J2ee1.3 server. it threw NoClassFoundException. what can i do/
thx
stephen chan
Originally posted by Rahul Mahindrakar:
I guess you have set the path to db2java.zip and not the class file by unziping it.
I have unziped my db2java.zip file and find in it tow DB2Driver.class files
The first one belongs to the "COM.ibm.db2.jdbc.app"
and the second one belongs to "COM.ibm.db2.jdbc.net" packages
I use the first one on my system as i could specify only that in my Websphere application server when configuring the driver.
Also it is strange that IBM uses the "COM" all in caps as packages are supposed to be in lowercase.
Please look at package names or write them carefully whenever you do so.
Why dont you try to change the HitCounterBean's DataSource to your DB2 database and restart the server. If you get any specific errors then we can look into it.
Hope we get it right this time

Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1844
Hi,
first,
Welcome to Javaranch. We follow some rules pertaining to User names. The rules are specified at here
Your User name does not follow these conventions. It is recommended that you immediately register under a name conforming to the conventions.
Second

I follow your description and unzip the db2java.zip file to a directory, let say "test". and then i set the classpath to the directory, it doesn't work, then i reset the classpath to the directory contains the two class files and run the program in J2ee1.3 server. it threw NoClassFoundException. what can i do/

In j2ee check up the documentation on how to set up the petstore demo for oracle. You can undertake similar steps for DB2 in J2EE. Basically you have to set the J2EE_CLASSPATH to the zip file. You do not need to extract it. I extracted it to see if the driver class file did exist and if so in which packages.
I was talking about setting up the DB2 driver for WebSphere not J2EE. We do have a forum for J2EE to. If you have additional problems do write.


------------------

Mahindrakar
IBM Application Server Forum Moderator
SCJP
stephen chan
Greenhorn

Joined: May 03, 2001
Posts: 6
hi,
My server is J2EE
My DB is DB2
when i unzip the db2java.zip file to a directory, let say "temp"
after i set the classpath and j2ee_classpath to the directory.
there is still an error which says "COM/ibm/db2/jdbc/app/db2java.zip" not found
would you help me
thx
stephen chan
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1844
Stephan

when i unzip the db2java.zip file to a directory, let say "temp"
after i set the classpath and j2ee_classpath to the directory.
there is still an error which says "COM/ibm/db2/jdbc/app/db2java.zip" not found

You do not need to unzip the zip file. just set the classpth to the zip file. Like
set J2EE_CLASSPATH=c:\db2java.zip;
You do have to change some properties (jdbc.datasources) in the default.properties that you find in the config folder of j2sdkee1.2.1.
However I cannot help you in this area as this forum is dedicated to Websphere Application Server(WAS) and IBM based products. Why dont't you put up your query in J2EE and EJB forum where you can get an appropriate reply. I would have transfered this thread over to that forum but this thread also has discussions on WAS so i cannot transfer this thread. Hope you put your query on
HOW to connect to DB2 from J2EE in the J2EE and EJB forum.

[This message has been edited by Rahul Mahindrakar (edited May 03, 2001).]
Harish SK
Greenhorn

Joined: Jun 01, 2001
Posts: 20
Hi,
I am new to websphere, worked in weblogic before, even I am getting this 'driver not found' problem with DB2, it works with oracle thin driver! I am using a datasource, and thought the classpath settign would be handled when you install DB2 driver on the admin console! should it be set in admin.config?
Harish SK
Greenhorn

Joined: Jun 01, 2001
Posts: 20
I INstalled the JDBC driver and tried setting classpath in bin\admin.config to db2java.zip(Rahul's message). Getting SQLException - Unable to Load Driver COM.ibm.db2.jdbc.app.DB2Driver.
I don't have any clue as I followed all instructions for creating a connection pool and thought WebSphere-DB2 connectivity was natural.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help on DB2
 
Similar Threads
WebSphere DB2 Connection Pool Setup
java.sql.SQLException: No suitable driver
Problem Loading DB2 Driver
codofobia
WebSphere V6.1 Db2 V8.1 Connection Problem