aspose file tools*
The moose likes JDBC and the fly likes java.sql.SQLException: No suitable driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException: No suitable driver" Watch "java.sql.SQLException: No suitable driver" New topic
Author

java.sql.SQLException: No suitable driver

Ganapathi Srinivasan
Greenhorn

Joined: Jan 17, 2003
Posts: 11
Hi,
I am trying to run a java program as an NT service that connects to an Oracle DB using a system DSN.
When I start the process under a domain user account I am getting the following excetion:
***EXCEPTION[java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
But the surprising fact is that when I do the same using the default SYSTEM account, the program is able to connect to the database and access records.
Can someone throw light as to why I get this particular problem?
Thanks in advance.
Ganapathi
[ July 09, 2003: Message edited by: Ganapathi Srinivasan ]
Marc Haberkorn
Greenhorn

Joined: Aug 15, 2002
Posts: 10
As part of its initialization, the DriverManager class will attempt to load the driver classes referenced in the "jdbc.drivers" system property. This allows a user to customize the JDBC Drivers used by their applications.
** THIS COULD MEAN THAT YOUR jdbc.drivers SYSTEM PROPERTIES DIFFER ON THE TWO DIFFERENT ACCOUNTS YOU'RE USING

For example in your ~/.hotjava/properties file you might specify:

jdbc.drivers=foo.bah.Driver:wombat.sql.Driver:bad.taste.ourDriver
A program can also explicitly load JDBC drivers at any time. For example, the my.sql.Driver is loaded with the following statement:
Class.forName("my.sql.Driver");
When the method getConnection is called, the DriverManager will attempt to locate a suitable driver from amongst those loaded at initialization and those loaded explicitly using the same classloader as the current applet or application.

That is from the JavaDoc of DriverManager, located at: http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DriverManager.html
Another possible problem is that you have different CLASSPATH variables set for the two different accounts. Thus, the driver is able to be found in one account and not in the other. Hopefully this helps some.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java.sql.SQLException: No suitable driver