【发布时间】:2014-11-11 06:01:15
【问题描述】:
我正在尝试一个程序来检查与下面的 oracle 数据库的连接
import java.sql.*;
class OracleCon{
public static void main(String args[]){
try{
//step1 load the driver class
Class.forName("oracle.jdbc.driver.OracleDriver");
//step2 create the connection object
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","SangamOne123");
//step3 create the statement object
Statement stmt=con.createStatement();
//step4 execute query
ResultSet rs=stmt.executeQuery("select * from emp");
while(rs.next()) {
System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));
}
//step5 close the connection object
con.close();
} catch(Exception e){
System.out.println(e);
}
}
}
但在 eclipse 中运行后,它显示以下异常。
java.sql.SQLException: Listener 拒绝与 以下错误:ORA-12505,TNS:listener 目前不知道 连接描述符中给出的 SID
请帮助我,我是 oracle 数据库的新手。
【问题讨论】: