ORA-12505, TNS:listener 当前不知道连接中给定的 SID
ORA-12505, TNS:listener does not currently know of SID given in connect
当我尝试与 hr/hr 用户创建数据库连接时,我正在使用 JDeveloper 我收到此消息:
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
然后我进入命令行并输入 tnsping ORCL
C:\Users\Administrator>tnsping ORCL
TNS Ping Utility for 64-bit Windows: Version 12.2.0.1.0 - Production on 20-FEB-2
018 15:55:23
Copyright (c) 1997, 2016, Oracle. All rights reserved.
Used parameter files:
C:\app\oracle\virtual\product.2.0\dbhome_1\network\admin\sqlnet.ora
Used EZCONNECT adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTO
COL=TCP)(HOST=213.130.77.281)(PORT=1521)))
OK (90 msec)
C:\Users\Administrator>é2@
并检查 Oracle 侦听器是否为 运行:
C:\Users\Administrator>lsnrctl status
LSNRCTL for 64-bit Windows: Version 12.2.0.1.0 - Production on 22-FEB-2018 12:34
:05
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=TESTINFRA)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 12.2.0.1.0 - Produ
ction
Start Date 20-FEB-2018 15:02:35
Uptime 1 days 21 hr. 31 min. 34 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File C:\app\oracle\virtual\product.2.0\dbhome_1\network\
admin\listener.ora
Listener Log File C:\app\oracle\virtual\diag\tnslsnr\TESTINFRA\listener\
alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=TESTINFRA)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\.\pipe\EXTPROC1521ipc)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
在你jdbc错误你正在使用:localhost:1521:ORCL
在TNSPING中是213.130.77.281
同样在jdev中使用ip地址。
您的侦听器服务没有明确说明它在此主机上有任何 ORCL 数据库 SID。
当您使用 TNSPING 命令检查连接性时,您通过使用 Oracle EZCONNECT 适配器解决了这个问题,该适配器本身解析所有需要的连接信息,但是 JDBC 驱动程序需要在侦听器中明确声明 SID 或清除命令才能使用 EZCONNECT 适配器。
所以有两种方法可以解决这个问题:
打开 listener.ora 并找到这些行:
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\app\oracle\virtual\product.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\app\oracle\virtual\product.2.0\dbhome_1\bin\oraclr11.dll")
)
)
将它们替换为:
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\app\oracle\virtual\product.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\app\oracle\virtual\product.2.0\dbhome_1\bin\oraclr11.dll")
)
(SID_DESC =
(SID_NAME = ORCL)
(ORACLE_HOME = C:\app\oracle\virtual\product.2.0\dbhome_1)
(GLOBAL_DBNAME = ORCL)
)
)
然后使用"lsnrctl stop"和"lsnrctl start"重新启动侦听器。此更改将在侦听器中注册新的 SID_DESC 块,其中包含您的数据库 SID 的描述。
更改 JDBC 字符串以通过 EZCONNECT 适配器而不是通过 SID 进行连接。请 post 你的 JDBC 连接字符串,如果你想要准确的答案,但总的来说你不应该使用:
jdbc:oracle:thin:@213.130.77.281:1521:orcl
并改用:
jdbc:oracle:thin:@//213.130.77.281:1521/orcl
此更改将告诉 JDBC 使用 EZCONNECT 适配器。
当我尝试与 hr/hr 用户创建数据库连接时,我正在使用 JDeveloper 我收到此消息:
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
然后我进入命令行并输入 tnsping ORCL
C:\Users\Administrator>tnsping ORCL
TNS Ping Utility for 64-bit Windows: Version 12.2.0.1.0 - Production on 20-FEB-2
018 15:55:23
Copyright (c) 1997, 2016, Oracle. All rights reserved.
Used parameter files:
C:\app\oracle\virtual\product.2.0\dbhome_1\network\admin\sqlnet.ora
Used EZCONNECT adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTO
COL=TCP)(HOST=213.130.77.281)(PORT=1521)))
OK (90 msec)
C:\Users\Administrator>é2@
并检查 Oracle 侦听器是否为 运行:
C:\Users\Administrator>lsnrctl status
LSNRCTL for 64-bit Windows: Version 12.2.0.1.0 - Production on 22-FEB-2018 12:34
:05
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=TESTINFRA)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 12.2.0.1.0 - Produ
ction
Start Date 20-FEB-2018 15:02:35
Uptime 1 days 21 hr. 31 min. 34 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File C:\app\oracle\virtual\product.2.0\dbhome_1\network\
admin\listener.ora
Listener Log File C:\app\oracle\virtual\diag\tnslsnr\TESTINFRA\listener\
alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=TESTINFRA)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\.\pipe\EXTPROC1521ipc)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
在你jdbc错误你正在使用:localhost:1521:ORCL
在TNSPING中是213.130.77.281
同样在jdev中使用ip地址。
您的侦听器服务没有明确说明它在此主机上有任何 ORCL 数据库 SID。 当您使用 TNSPING 命令检查连接性时,您通过使用 Oracle EZCONNECT 适配器解决了这个问题,该适配器本身解析所有需要的连接信息,但是 JDBC 驱动程序需要在侦听器中明确声明 SID 或清除命令才能使用 EZCONNECT 适配器。
所以有两种方法可以解决这个问题:
打开 listener.ora 并找到这些行:
(SID_LIST = (SID_DESC = (SID_NAME = CLRExtProc) (ORACLE_HOME = C:\app\oracle\virtual\product.2.0\dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=ONLY:C:\app\oracle\virtual\product.2.0\dbhome_1\bin\oraclr11.dll") ) )
将它们替换为:
(SID_LIST = (SID_DESC = (SID_NAME = CLRExtProc) (ORACLE_HOME = C:\app\oracle\virtual\product.2.0\dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=ONLY:C:\app\oracle\virtual\product.2.0\dbhome_1\bin\oraclr11.dll") ) (SID_DESC = (SID_NAME = ORCL) (ORACLE_HOME = C:\app\oracle\virtual\product.2.0\dbhome_1) (GLOBAL_DBNAME = ORCL) ) )
然后使用"lsnrctl stop"和"lsnrctl start"重新启动侦听器。此更改将在侦听器中注册新的 SID_DESC 块,其中包含您的数据库 SID 的描述。
更改 JDBC 字符串以通过 EZCONNECT 适配器而不是通过 SID 进行连接。请 post 你的 JDBC 连接字符串,如果你想要准确的答案,但总的来说你不应该使用:
jdbc:oracle:thin:@213.130.77.281:1521:orcl
并改用:
jdbc:oracle:thin:@//213.130.77.281:1521/orcl
此更改将告诉 JDBC 使用 EZCONNECT 适配器。