Reputation: 604
I am trying to connect to an oracle database in eclipse. I have ojdbc14.jar in a lib folder in the same project and i added it to the build path of my project, so it also resides in the Referenced Libraries directory, but yet i still get an output to the console of "Could not find the database driver"
Myself and another student employee have been trying to get this figured out for the past day and a half, and no one else in our department is experienced in Java and JSP so i thought StackOverflow would be our best bet =)
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
System.out.println("Attempting to load the driver...");
Class.forName(driverName);
System.out.print("Loaded the driver");
// Create a connection to the database
String serverName = " ;) ";
String portNumber = " ;) ";
String sid = " ;) ";
String url = "jdbc:oracle:thin:@" + serverName + ":"
+ portNumber + ":" + sid;
String username = "kenne13";
String password = "**********";
connection = DriverManager.getConnection(url, username, password);
if (connection != null) {
return true;
}
} catch (ClassNotFoundException e) {
// Could not find the database driver
System.out.println("Could not find the database driver");
connected = false;
} catch (SQLException e) {
// Could not connect to the database
System.out.println("Could not connect to the database");
connected = false;
}
Here is the output in the console:
Aug 18, 2011 10:07:50 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 382 ms
Attempting to load the driver...
Could not find the database driver
Here is a screen capture of the code, the error, and my project directories.
Upvotes: 1
Views: 7665
Reputation: 101
Go to the deploy folder(C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps) of your web app and make sure that ojdbc14.jar is there.
Upvotes: 0
Reputation: 3429
In a related post: Cannot find Oracle jdbc driver
the problem was solved adding the oracle library in the run path. Have you tried to configure too? (Run/Run Configurations Select your configuration/classpath tab)
Upvotes: -1
Reputation: 29877
I'm quite sure now that the class name of the driver is oracle.jdbc.OracleDriver
and not oracle.jdbc.driver.OracleDriver
.
Upvotes: 3