【问题标题】:Why my sqlplus string connection only works with /service_name and not with :service_name为什么我的 sqlplus 字符串连接仅适用于 /service_name 而不适用于 :service_name
【发布时间】:2019-05-22 04:20:13
【问题描述】:

我正在尝试使用 sqlplus 连接我的数据库,使用分号传递服务,但无法正常工作,只能使用斜杠。

 [root@38324e46bdc6 bin]# sqlplus ECM/ECM@//172.18.0.5:1521:ORACLEDB.localdomain

    SQL*Plus: Release 12.1.0.2.0 Production on Fri Dec 21 16:18:50 2018

    Copyright (c) 1982, 2014, Oracle.  All rights reserved.

    ERROR:
    ORA-12154: TNS:could not resolve the connect identifier specified

但是,这样:

 [root@38324e46bdc6 bin]# sqlplus ECM/ECM@172.18.0.5:1521/ORACLEDB.localdomain

    SQL*Plus: Release 12.1.0.2.0 Production on Fri Dec 21 16:10:21 2018

    Copyright (c) 1982, 2014, Oracle.  All rights reserved.

    Last Successful login time: Fri Dec 21 2018 16:09:44 +00:00

    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

    SQL> 

这是我的听众:

 [oracle@3fa66b9377b9 /]$ lsnrctl status listener

    LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 21-DEC-2018 17:31:21

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

    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.0.0.0)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
    Start Date                18-DEC-2018 18:02:23
    Uptime                    2 days 23 hr. 28 min. 57 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORACLEDB/listener.ora
    Listener Log File         /u01/app/oracle/diag/tnslsnr/3fa66b9377b9/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=3fa66b9377b9)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/product/12.2.0/dbhome_1/admin/ORACLEDB/xdb_wallet))(Presentation=HTTP)(Session=RAW))
    Services Summary...
    Service "7d50b1bde0ed0114e053050012ac954b.localdomain" has 1 instance(s).
      Instance "ORACLEDB", status READY, has 1 handler(s) for this service...
    Service "ORACLEDB.localdomain" has 1 instance(s).
      Instance "ORACLEDB", status READY, has 1 handler(s) for this service...
    Service "ORACLEDBXDB.localdomain" has 1 instance(s).
      Instance "ORACLEDB", status READY, has 1 handler(s) for this service...
    Service "orclpdb1.localdomain" has 1 instance(s).
      Instance "ORACLEDB", status READY, has 1 handler(s) for this service...
    The command completed successfully

问题是我需要使用分号并且能够以这种方式连接:

sqlplus ECM/ECM@//172.18.0.5:1521:ORACLEDB.localdomain

因为项目稍后会解析 xml 文件并像 port:host:sid 一样连接,所以我无法更改元数据以使用 /sid 。 有人可以帮我吗?

【问题讨论】:

  • SID 和服务名称不是一回事。它是/service_name:SID ...并且SID 中没有句点/句号。您的听众可能没有设置sid_list_listener;并且在 12c 中,无论如何默认情况下您都无法使用 SID 进行连接。

标签: oracle listener sqlplus tnsnames


【解决方案1】:

嗯,我发现了问题。 基本上,jdbc 连接器使用的是 USER/PASSWORD@HOST:SID 而 sqlplus 是 PASSWORD/USER@HOST/SERVICE。

谢谢!

【讨论】:

    猜你喜欢
    • 2019-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-13
    • 1970-01-01
    • 2015-11-23
    • 2017-10-15
    相关资源
    最近更新 更多