aspose file tools*
The moose likes JDBC and the fly likes HELP 2 !!!!!!!!! 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 "HELP 2 !!!!!!!!!" Watch "HELP 2 !!!!!!!!!" New topic
Author

HELP 2 !!!!!!!!!

Hrvoje Canzek
Greenhorn

Joined: Sep 18, 2002
Posts: 16
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 ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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 ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"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
Hrvoje Canzek
Greenhorn

Joined: Sep 18, 2002
Posts: 16
is this username better ??
i wrote this
con = DriverManager.getConnection("jdbc b2 bname","user","passwd");
but the problem is the same
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
"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"
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
Oops, something I missed earlier... you are not registering your Driver. Check out DriverManager.registerDriver().
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Hrvoje_Canzek",
Sorry to annoy you, but your name is still not correct, you must have two words separated by a space.
It appears you should alter it to "Hrvoje Canzek".
Thanks.
Dave
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

[ 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
Hrvoje Canzek
Greenhorn

Joined: Sep 18, 2002
Posts: 16
My jdbc driver is loaded :
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
System.out.println("Driver loaded");
this system.out is displayed,problem is the getConnection part !!!
???
Hrvoje Canzek
Greenhorn

Joined: Sep 18, 2002
Posts: 16
i got it by typing
java -Djdbc.drivers=DriverClass ApplikationName
example:
java -Djdbc.drivers=
COM.ibm.db2.jdbc.app.DB2Driver DBtest
juhu ;-)
Hrvoje Canzek
Riaz Mohamed
Greenhorn

Joined: May 31, 2002
Posts: 23
Hi
Could u try this instead
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
url=jdbc b2://" + dbHost + "/" + dbName
If you do face more problems lemme know will send u the complete code
regards
riaz
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: HELP 2 !!!!!!!!!