I tried this : Class.forName("COM.ibm.db2.jdbc.app.DB2Driver"); con = DriverManager.getConnection("jdbc:Db2:DbName","user","passwd"); but then this error came: java.sql.SQLException: No suitable driver
what's wrong ??? [ Edited by Dave to remove smilies ] [ September 18, 2002: Message edited by: David O'Meara ]
Isn't it meant to be lowercase 'db2' in the URL? As in jdbc:db2:DbName ? I wasn't aware URLs were case sensetive, but it wouldn't surprise me. [ Oops, crazy typo ] [ September 18, 2002: Message edited by: David O'Meara ]
"HowyC", The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp. We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements. Be sure to read the naming convention HowyC is not valid and neither is Howy C. C Howy is barely legal. Thanks. Dave
"No suitable driver" usually can be corrected by your CLASSPATH. Double-check your CLASSPATH and make sure that your driver class is in there somewhere. Also, It seems odd that "COM." is in upper-case. Package names are case-sensitive.
Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
No, you shouldn't call DriverManager.registerDriver explicitly. The Class.forName should allow the DRiver to register itself when it loads. If you are using an older API, you might try Class.forName(...).newInstance(); There was a bug in these versions where static blocks didn't get called until an instance is created. From the Java JDBC FAQ:
9. What causes the "No suitable driver" error? "No suitable driver" is an error that usually occurs during a call to the DriverManager.getConnection method. The cause can be failing to load the appropriate JDBC drivers before calling the getConnection method, or it can be specifying an invalid JDBC URL--one that isn't recognized by your JDBC driver. Your best bet is to check the documentation for your JDBC driver or contact your JDBC driver vendor if you suspect that the URL you are specifying is not being recognized by your JDBC driver. In addition, when you are using the JDBC-ODBC Bridge, this error can occur if one or more the the shared libraries needed by the Bridge cannot be loaded. If you think this is the cause, check your configuration to be sure that the shared libraries are accessible to the Bridge.
I believe the 'COM.ibm' package is also correct. Frustratingly, IBM tend to wander between the two.
[ This was posted in a new topic and I believe it belongs in this one...]
Originaly posted by Hrvoje_Canzek i use the following code in my application: Class.forName("COM.ibm.db2.jdbc.app.DB2Driver"); con = DriverManager.getConnection("jdbc b2 bName","user","passwd"); my classpath : set classpath=.;c:\SQLLIB\java\db2java.zip; c:\SQLLIB\lib;c:\SQLLIB\java\runtime.zip; c:\SQLLIB\java\sqlj.zip Please help me i do not know what to do