aspose file tools*
The moose likes JDBC and the fly likes jdbc, db2, no suitable driver, linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc, db2, no suitable driver, linux" Watch "jdbc, db2, no suitable driver, linux" New topic
Author

jdbc, db2, no suitable driver, linux

Bo Lin
Greenhorn

Joined: Nov 17, 2002
Posts: 6
Hello, we have a java program that calls db2 on our solaris/unix server. If I login as user1 and run it it works, but if I login as user2 and try to run it, it throws a "No Suitable Driver" error. So it looks like a classpath issue, BUT i am able to compile the code under both logins just fine which means it is able to find the db2 db2java.zip driver, right?
Now we need to move the program over to redhat linux enterprise, again i setup the classpath etc.. and it compiles fine but when i try to run it I get the same "No Suitable Driver" error.
The Class.forName path is"COM.ibm.db2.jdbc.app.DB2Driver"; I am almost 100% certain this is not the issue and dont want to change it unless it will fix the problem.
I am a bit unsure where to begin now to fix this problem, the driver is in the classpath after all and the class.forname is correct. What else could be causing this error?
Thank you,
gaga
Tony Yan
Ranch Hand

Joined: Apr 10, 2002
Posts: 170
Hi,
By any chance, that user1 and user2 are getting different URL? No Suitable Driver typically is caused by wrong URL, instead of CP problem. The latter generates "ClassNotFound".


Tony Yan<br /> <br />IBM Certified Developer XML and Related Technology<br />Sun Certified Web Component Developer For J2EE Platform<br />Sun Certified Programmer For Java 2 Platform
Bo Lin
Greenhorn

Joined: Nov 17, 2002
Posts: 6
hello by URL you mean "COM.ibm.db2.jdbc.app.DB2Driver" ?
that is constant, it does not change. Thanks
Tony Yan
Ranch Hand

Joined: Apr 10, 2002
Posts: 170
No. The datasource string, something like this:
jdbc:sybase:Tds:localhost:5000
Of course, this is for my desktop sybase. Check your db2 url. I tried, when I change this URL, I got same no suitable driver error from JDBC. But I just wonder why changing a user resulted this (normally, url doesn't change for different user, right?)
Bo Lin
Greenhorn

Joined: Nov 17, 2002
Posts: 6
yeah exactly, the db url is constant too.
Tony Yan
Ranch Hand

Joined: Apr 10, 2002
Posts: 170
Pretty weird. I assume you get this NSD error when DriverManager.getConnection(url, name, pass)? If that's the case, maybe the db2 is not allowing user2 to get a remote connection. Just a speculation here.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

I suspect that you have either:
1. A permission's error ( user2 does not have permissions to see the DB2 driver jar file )
2. user2's classpath setting is different than user1, and the user2's classpath does not include the DB2 driver jar file.

Jamie
for the record, I'm not a UNIX guru to say the least, but this is an error message that comes from the DB2 driver jar file in a different location ( or not at all ) than the classpath says it should be or a misspelling or capitalization error when loading the driver.
Jamie
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

I just noticed that the URL I use to load the JTOPEN DB2 driver is different than the URL you use:
I use:
//load the IBM driver class used to connect to the DB2 database
DriverManager.registerDriver( new com.ibm.db2.jdbc.app.DB2Driver() );
where as you use:
"COM.ibm.db2.jdbc.app.DB2Driver"
Notice your use of capitalization on the first part of the package name. All packages are in lower case. Change your driver loading code to the line I provided and see if it works.
Jamie
 
wood burning stoves
 
subject: jdbc, db2, no suitable driver, linux