ORA-12505,TNS:当连接为JDBC远程客户端时,侦听器当前不知道连接描述符中给出的SID

时间:2016-10-25 03:32:08

标签: oracle jdbc

我已经完成了很多人为这个查询提出的所有建议。但不幸的是,他们都没有解决我的问题。

问题: - 我已将Oracle12c安装到我们的远程计算机(Host1)中,默认情况下ORCL数据库已创建并正在运行。之后,通过使用Database configuration Assistant,我创建了新的数据库" YILIDB"。我可以通过sqldeveloper工具从Host1连接到这些数据库。但是,当我试图从另一台机器(Host2)访问上述数据库时,我无法连接到它。首先,我尝试使用JDBC代码连接到该数据库。我得到了以下例外。

代码: -

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:172.26.8.188:1521:YILIDB", "WM6",
                "WM6");

错误: -

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
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:825)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:755)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:38)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:599)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at ConnectionTest.main(ConnectionTest.java:39)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

    at oracle.net.ns.NSProtocolStream.negotiateConnection(NSProtocolStream.java:324)
    at oracle.net.ns.NSProtocol.connect(NSProtocol.java:287)
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1963)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:564)
    ... 6 more

当我尝试从Host2 sqldeveloper连接到Host1数据库时,我得到了以下错误,这意味着基本上我无法使用JDBC代码连接到远程数据库,也不能使用sqldeveloper。

我尝试从sqldeveloper连接时出错: -

  

状态:测试失败:网络适配器无法建立连接的IO错误

在远程数据库机器中,我验证了服务。 ORCL和YILIDB服务都在运行。我看到服务中只有一个监听器正在运行。

有人可以为我提供解决方案。

下找到> lsnrctl状态的状态
C:\Users\Administrator>lsnrctl status

LSNRCTL for 64-bit Windows: Version 12.1.0.1.0 - Production on 25-OCT-2016 14:14:41

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER

Version                   TNSLSNR for 64-bit Windows: Version 12.1.0.1.0 - Production

Start Date                25-OCT-2016 14:04:56
Uptime                    0 days 0 hr. 9 min. 44 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           YILIDB
Listener Parameter File   C:\app\Administrator\product\12.1.0\dbhome_1\network\admin\listener.ora
Listener Log File         C:\app\Administrator\diag\tnslsnr\SMYB2SW12-Yili\listener\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.pipe\EXTPROC1521ipc)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.28.8.199)(PORT=1521)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

1 个答案:

答案 0 :(得分:1)

通过使用@。

更改jdbc url已解决此问题

此前:

JDBC:预言:瘦:123.45.6.78:1521:YILIDB

现在:

JDBC:预言:瘦:@ 123.45.6.78:1521:YILIDB