This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Cannot connect to Oracle Database No suitable Driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Cannot connect to Oracle Database No suitable Driver" Watch "Cannot connect to Oracle Database No suitable Driver" New topic
Author

Cannot connect to Oracle Database No suitable Driver

michael turner
Greenhorn

Joined: Oct 28, 2003
Posts: 23
All:

Any help rendered would be appreciated. (jdk 1.4.2_06, Tomcat 4.0,
Oracle DB 9i Windows XP)

I have a web app (Jasper report tool) and I cannot connect to a Oracle 9i database.

1)error received: "Apr 2, 2007 2:05:15 PM com.entDB.Enterprise_db connectToDatabase SEVERE: Function connectToDatabase() - Cannot load the driver, reason:java.sql.SQLException: No suitable driverCheck classpath for driver java.sql.SQLException: No suitable driver


2)CLASSPATH SETTING = C:\tomcat\common\lib\ojdbc14.jar


3)Source code:
protected boolean connectToDatabase() {

try {
// I tried this !!! Class.forName("oracle.jdbc.driver.OracleDriver");
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection("URL,USER,PASSWORD ");
return true;
}catch (SQLException e) {
logger.error("Function connectToDatabase() - Cannot load the driver, reason:" + e.toString() + "Check classpath for driver ", e);
return false;
}

4.I placed a copy of the jar file in TOMCAT common lib, and server lib.
I have tried various solutions listed at different web sites without success. Has anyone had similiar problems? Can anyone assist?

thanks ......



[edited subject to remove "911" - nothing is on fire]
[ April 02, 2007: Message edited by: Jeanne Boyarsky ]
michael turner
Greenhorn

Joined: Oct 28, 2003
Posts: 23
*************** FOUND THE ERROR ******************

I was in a hurry when typing the error is:

con = DriverManager.getConnection("URL,USER,PASSWORD ");

This should be con = DriverManager.getConnection(URL,USER,PASSWORD);

For previously declared strings.

Thanks .......

:p
Mandar Velankar
Ranch Hand

Joined: Jul 31, 2006
Posts: 32
Hi Michael,

I have gone through similar problem just 2 days earlier. Check out entier post
under my name.Follow the instructions given by Paul. Do not comment out Class.forName statement , it is necessary , it will load driver and register driver with DriverManager. Most of the time there is no requirement for registerDriver statement , Class.forName does it automatically.
First check whether it will load your driver class or not and then finally check your URL , it is also imp.
Normally URL is jdbc racle:thin:@localhost:1521:gj1
where gj1 is my database global SID (identifier).

Hope it will help you.



Regards,
Mandar Velankar
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Cannot connect to Oracle Database No suitable Driver
 
Similar Threads
Tomcat 5.5 and simple JDBC program issue
jdbc oracle hell......
Driver Problem
Tomcat and jdbc problem
jdbc oracle hell