这是我的程序:import java.sql.*;public class TestJDBC { public static void main(String[] args) {

Connection conn = null;
Statement statm = null;
ResultSet rs = null;

try {
Class.forName("oracle.jdbc.driver.OracleDriver");
//new oracle.jdbc.driver.OracleDriver();
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
}

try {
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@127.0.0.1:1521:ORCL", "scott", "tiger");
statm = conn.createStatement();
rs = statm.executeQuery("select * from dept");
while (rs.next()) {
System.out.println(rs.getString("deptno"));
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (statm != null) {
statm.close();
statm = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}总是报如下错误:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
127.0.0.1:1521:ORCL我检查了我的服务和监听都启动了,classes12.jar也引入了:为什么还抱着这样错?请大家帮帮忙, 万分感谢!!!!

解决方案 »

  1.   

    不是给你说了吗
    listener does not currently know of SID given in connect descriptor
    SID不认识,确认一下你的数据库SID
      

  2.   

    楼上几位说的都对,检查你数据库的SID吧!
      

  3.   

    用你的配置助手重新配一下oracle网络服务名
      

  4.   

    首先谢谢各位, sid是指数据库名吧? 我的数据库名就是ORCL,  再请大家一下那里出错了, 昨晚我也是这样的, 连接成功了, 可是今天就是怎么死活也连不上, 谢谢大家, 帮帮我看下错在那里!!!
      

  5.   

    url 的端口号后面跟的不是网络服务名,而是数据库的 sid