Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HELP 2 !!!!!!!!!

 
Hrvoje Canzek
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, something I missed earlier... you are not registering your Driver. Check out DriverManager.registerDriver().
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[ 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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic