try {
//加载一个Oracle驱动
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//使用OCI8连接到数据库
conn=DriverManager.getConnection("jdbc:oracle:oci8:@DatabaseName"+,"user","password");
}catch(SQLException e) { //捕捉SQL违例
System.out.println("Ora8iConnect在连接oracle8数据库时捕获");
while (e!=null)
{ System.out.println("SQLState:"+e.getSQLState());
System.out.println("Message :"+e.getMessage());
System.out.println("Vendor :"+e.getErrorCode());
e=e.getNextException();
System.out.println(" ");
}
conn=null;
}
try {
时间: 2024-10-01 17:41:40