刚装了个oracle11g,然后尝试连接,没想到连接失败,错误代码如下:
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:
localhost:1521:oracle
程序中方法如下:
- Java code
public static Connection getConnection() { Connection conn = null; String driver ="oracle.jdbc.driver.OracleDriver"; String url = "jdbc:oracle:thin:@localhost:1521:oracle"; String uName = "scott"; String pswd = "tiger"; try { Class.forName(driver); conn = DriverManager.getConnection(url, uName, pswd); } catch (ClassNotFoundException e) { System.out.println("类加载错误"+e.getMessage()); } catch (SQLException e) { System.out.println("连接错误"+e.getMessage()); e.printStackTrace(); } return conn; }
请问下是哪里出了问题啊,急
------解决方案--------------------------------------------------------
oracle监听启动了吗?1521端口通吗?