我自己又建了一个数据库实例 全局名称叫panfeng
监听(OracleOraDb11g_home1TNSListener)
和数据库服务(OracleServicePANFENG)都开了
我用这个连接地址报错了(String url = "jdbc:oracle:thin:@localhost:1521:panfeng")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
代码
public class BaseDao {
String url = "jdbc:oracle:thin:@localhost:1521:PANFENG"; // 连接字符串
String className = "oracle.jdbc.OracleDriver"; // 驱动
String userName = "pan"; // 用户名
String userPass = "123"; // 用户密码 public Connection getConn() { // 连接
Connection conn = null;
try {
Class.forName(className);
conn = DriverManager.getConnection(url,userName,userPass);
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}
怎么解决阿..在线等oracle数据库jdbc

解决方案 »

  1.   

    你的SID 不识别,请检查一下你的oracle的  本地Net服务名配置   ,配置好后,测试一下能否连接成功
      

  2.   

    "jdbc:oracle:thin:@localhost:1521:panfeng" 这里的panfeng应该是你配置好后的服务名
    对应的URL为:"jdbc:oracle:thin:@localhost:1521:ORCL"
      

  3.   

    TNS:listener does not currently know of SID given in connect descriptor
    SID is wrong.