找到Oracle數據庫驅動程序,我試圖連接到Oracle數據庫中的日食。我在同一個項目的lib文件夾中添加了ojdbc14.jar,並將其添加到我的項目的構建路徑中,因此它也駐留在Referenced Libraries目錄中,但我仍然得到輸出到控制檯「Could not find數據庫驅動程序「不能在Eclipse JAVA程序
我和另一位學生員工一直試圖在過去的一天半里得出這個結論,我們部門中沒有其他人在Java和JSP方面有經驗,所以我認爲StackOverflow將是我們最好的賭注=)
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;
}
這裏是在控制檯輸出:
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是代碼,錯誤和我的項目目錄的屏幕截圖。
你可以嘗試改變與'oracle.jdbc.OracleDriver'驅動類的名字嗎? – Augusto
試過了,但仍然捕獲ClassNotFoundException並顯示相同的錯誤??? –