ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
使用jdbc连接数据库,出现:
ava.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:
localhost:1521:ora10
解决方法:
1.到相应的oracle安装目录下,找到listener.ora 和 tnsnames.ora看看里面的端口配置是否是默认的1521,在程序中应该使用在listener.ora中配置的端口号
D:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\listener.ora
2.以下出自:http://joanzq.**.com/blog/264593
oracle10G 的ORA-12505问题解决方法
连接 jdbc Oracle10g 错误 ,JDBC代码无问题,服务也启动,连接字符串也是对的,但是在eclipse 下报错,错误信息如下:
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:
localhost:1521:orcl
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:279)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:318)
at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:343)
at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:147)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:31)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:545)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at cn.com.db.DBAccess.getConnection(DBAccess.java:33)
at cn.com.db.DBAccess.main(DBAccess.java:95)
Null
在CMD下snrctl status ,tnsping orcl 显示都正常。
在pl/SQL下用
select open_mode from v$database;
show parameter instance;
select INSTANCE_NAME from v$instance;
sqlplus sys/oracle@orcl
查询都显示正常,就是用pl/sql 登录时 填“数据库名” orcl 就无法登陆,报ora -12514
l最后有效的解决方法:
修改listener.ora文件
原listener.ora文件:
# listener.ora Network Configuration File: D:\oracle\product\10.1.0\Db_4\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\product\10.1.0\Db_4)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
)
修改后的文件:
---------------------------------------------------------------------------------------
# listener.ora Network Configuration File: D:\oracle\product\10.1.0\Db_4\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\product\10.1.0\Db_4)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = D:\oracle\product\10.1.0\Db_4)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
)
ava.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:
localhost:1521:ora10
解决方法:
1.到相应的oracle安装目录下,找到listener.ora 和 tnsnames.ora看看里面的端口配置是否是默认的1521,在程序中应该使用在listener.ora中配置的端口号
D:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\listener.ora
2.以下出自:http://joanzq.**.com/blog/264593
oracle10G 的ORA-12505问题解决方法
连接 jdbc Oracle10g 错误 ,JDBC代码无问题,服务也启动,连接字符串也是对的,但是在eclipse 下报错,错误信息如下:
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:
localhost:1521:orcl
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:279)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:318)
at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:343)
at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:147)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:31)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:545)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at cn.com.db.DBAccess.getConnection(DBAccess.java:33)
at cn.com.db.DBAccess.main(DBAccess.java:95)
Null
在CMD下snrctl status ,tnsping orcl 显示都正常。
在pl/SQL下用
select open_mode from v$database;
show parameter instance;
select INSTANCE_NAME from v$instance;
sqlplus sys/oracle@orcl
查询都显示正常,就是用pl/sql 登录时 填“数据库名” orcl 就无法登陆,报ora -12514
l最后有效的解决方法:
修改listener.ora文件
原listener.ora文件:
# listener.ora Network Configuration File: D:\oracle\product\10.1.0\Db_4\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\product\10.1.0\Db_4)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
)
修改后的文件:
---------------------------------------------------------------------------------------
# listener.ora Network Configuration File: D:\oracle\product\10.1.0\Db_4\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\product\10.1.0\Db_4)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = D:\oracle\product\10.1.0\Db_4)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26842371/viewspace-720762/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26842371/viewspace-720762/