This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.SQLException: No suitable driver in DB2 7.01

 
Hd Desai
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using DB2 7.01 client.And our database is on OS 390.

I am using this code to connect to database.

try {
String dbUserName = "";
String dbPassword = "";
String dbUrl = "";
String dbDriver = "";
dbUrl = "jdbc b2os390:ADDCDB2P";
dbUserName = "t4745kb";
dbPassword = "may02005";

Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
Connection conn = DriverManager.getConnection (dbUrl,dbUserName,dbPassword);

}
catch(ClassNotFoundException e){
e.printStackTrace();
}
catch(SQLException sqle) {
sqle.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}


} // End of getNewConn()

But its giving me following exception

java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:563)
at java.sql.DriverManager.getConnection(DriverManager.java:194)
at com.dcx.parts.ao.Test.getNewConn(Test.java:63)
at com.dcx.parts.ao.Test.main(Test.java:39)


My db2java.zip is in buildpath of WSAD 5.1

Pls help me in this regard.

Thnx
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your URL is blank (the String dbUrl). You will need to give theDriverManager a valid URL for your database.
 
Hd Desai
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i have alredy assigned a value to that variable.

You can check

dbUrl = "jdbc b2os390:ADDCDB2P";

in code,its already there.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah sorry, missed that (why do you create a blank string, then create another with the correct value in it? ).

Well this error occurs when either your jdbc URL is unrecognized (which doesn't look like the case) or your driver in not in the classpath of you applciation. You say you include it in the "buildpath" for WSAD. Is that the same thing as the classpath WAS uses?
 
Jon Egan
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this correct:



I've never seen a package name start with "COM", I would have expected to see "com".... Package/Class names are case-sensitive.

Also, I only have old code for this type of thing, and maybe it's not necessary anymore, but i use:



where "driverClassName" is a String holding the package/class name for the driver.

And then I'm able to use "DriverManager.getConnection()...".

Hope this helps.

--Jon
 
Joe Intrakamhang
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your url set with a colon after the jdbc like this?
jdbc:b2os390:ADDCDB2P

Also make sure your db2java.zip is in your classpath.

I hope this helps.

-Joe
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic