aspose file tools*
The moose likes JDBC and the fly likes DB2 driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DB2 driver" Watch "DB2 driver" New topic
Author

DB2 driver

Vidya Ram
Ranch Hand

Joined: Apr 22, 2003
Posts: 62
Hi all,
I just downloaded DB2 UDB version 8 trial version & tried to access the database (I used the following code to register and load the driver), but I get an error that package COM.ibm.db2.jdbc.app doesn't exist. I have added the db2jcc.jar and sqlj.zip files in my classpath.
DriverManager.registerDriver(new COM.ibm.db2.jdbc.app.DB2Driver());
Class db2Driver = Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
Could anybody who has worked on DB2 can give me some pointers about this error? I tried to find the class file DB2Driver myself in all the library files that came with DB2, but I didn't find the one required :-(
I found only one DB2Driver class file in db2cc.jar which is in package com.ibm.db2.jcc
Any help is greatly appreciated.
Thanks,
Vidya.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30752
    
156

The files you are looking for are in db2java.zip. On my machine, it's in .../sqllib/java/db2java.zip.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Vidya Ram
Ranch Hand

Joined: Apr 22, 2003
Posts: 62
Thanks Jeanne. I can compile the code now but it gives an "SQL exception:No suitable driver found".
Could you please let me know what could be wrong?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30752
    
156

That could be one of many problems.
1) What IDE are you using or are you using the command line?
2) Are you accessing the database from JDBC or EJBs?
Dana Hanna
Ranch Hand

Joined: Feb 28, 2003
Posts: 227
What is the URL that you are using? It should look like:

DriverManager.getConnection("jdbc b2:<database_name>", "<user>", "<pass");

FYI -
default user and pass are "dba", "dba" and "db2admin", "db2admin" for DB2...
Vidya Ram
Ranch Hand

Joined: Apr 22, 2003
Posts: 62
Thank you Jeanne and Dana, it works fine now.
I am using command line and using JDBC to access the database.
I was trying with the URL jdbc b2://localhost:50000/Vidya","dba","dba" Then it gave me that error. I was under the impression that I should specify the port number also as we do for Oracle...
Thanks again.
Vidya.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DB2 driver