*
The moose likes JDBC and the fly likes java.sql.SQLException: No suitable driver in DB2 7.01 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 » Databases » JDBC
Bookmark "java.sql.SQLException: No suitable driver in DB2 7.01" Watch "java.sql.SQLException: No suitable driver in DB2 7.01" New topic
Author

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

Hd Desai
Ranch Hand

Joined: Aug 04, 2003
Posts: 65
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

Joined: Apr 14, 2004
Posts: 10336

Your URL is blank (the String dbUrl). You will need to give theDriverManager a valid URL for your database.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Hd Desai
Ranch Hand

Joined: Aug 04, 2003
Posts: 65
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

Joined: Apr 14, 2004
Posts: 10336

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

Joined: Mar 24, 2004
Posts: 83
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

Joined: Apr 26, 2005
Posts: 5
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
 
subject: java.sql.SQLException: No suitable driver in DB2 7.01
 
Similar Threads
Establishing Connection to MS Access Databases
Urgent: Driver class loaded but getting no suitable driver found exception
java.sql.SQLException: No suitable driver
ClassNotFoundException while trying to connect to Oracle
No suitable Driver in DB2