下面是我的 JDBC Oracle Connectivity 的简单程序。请查看并告诉我为什么我可能会收到驱动程序未加载的错误。我已经放入odbc14.jar
图书馆。
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package databaseconnect;
/**
*
* @author compaq
*/
import java.sql.*;
public class Education1 {
public static void main(String[] args) {
try{
Class.forName("oracle:jdbc:driver:OracleDriver");
}catch( Exception e ) {
System.out.println("Failed to load Oracle driver.");
}
try{
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","system");
Statement stmt=con.createStatement();
stmt.executeUpdate("insert into Education(name,rollno) VALUES ('alankrit',1000)");
System.out.println("Data inserted");
con.close();
} catch(Exception e){
// System.out.println(e);
}
}
}