Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB2 driver

 
Vidya Ram
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The files you are looking for are in db2java.zip. On my machine, it's in .../sqllib/java/db2java.zip.
 
Vidya Ram
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic