原 Oracle登录报错ORA-12504: TNS: 监听程序在 CONNECT_DATA 中未获得 SERVICE_NAME
现象
版本:11.2.0.1
ORA-12504: TNS: 监听程序在 CONNECT_DATA 中未获得 SERVICE_NAME
ORA-12543: TNS: 无法连接目标主机
ORA-12543: TNS:destination host unreachable
EZConnect or Hostname Adapter Usage: ORA-12504 (Doc ID 2550189.1)
APPLIES TO:
Oracle Net Services - Version 11.2.0.3 to 18.1.0.0.0 [Release 11.2 to 18.1]
Information in this document applies to any platform.
SYMPTOMS
While attempting to use the EZCONNECT Naming adapter, the following error is returned:
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
Example:
sqlplus system@hostname.domain:port/service_name
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
An Oracle Net trace reveals that the SERVICE_NAME field is not populated when the connection attempt is being made:
(4111095552) [17-APR-2019 22:13:40:047] nspsend: 00 00 28 44 45 53 43 52 |..(DESCR|
(4111095552) [17-APR-2019 22:13:40:047] nspsend: 49 50 54 49 4F 4E 3D 28 |IPTION=(|
(4111095552) [17-APR-2019 22:13:40:047] nspsend: 43 4F 4E 4E 45 43 54 5F |CONNECT_|
(4111095552) [17-APR-2019 22:13:40:047] nspsend: 44 41 54 41 3D 28 53 45 |DATA=(SE|
(4111095552) [17-APR-2019 22:13:40:047] nspsend: 52 56 49 43 45 5F 4E 41 |RVICE_NA|
(4111095552) [17-APR-2019 22:13:40:047] nspsend: 4D 45 3D 29 28 43 49 44 |ME=)(CID|<===nothing in SERVICE_NAME field
(4111095552) [17-APR-2019 22:13:40:047] nspsend: 3D 28 50 52 4F 47 52 41 |=(PROGRA|
(4111095552) [17-APR-2019 22:13:40:047] nspsend: 29 29 |)) |
(4111095552) [17-APR-2019 22:13:40:048] niqme: entry
(4111095552) [17-APR-2019 22:13:40:048] niqme: reporting NS-12564 error as ORA-12564
(4111095552) [17-APR-2019 22:13:40:055] niqme: exit
(4111095552) [17-APR-2019 22:13:40:055] niomapnserror: exit
(4111095552) [17-APR-2019 22:13:40:055] niqme: entry
(4111095552) [17-APR-2019 22:13:40:055] niqme: reporting NSG-12504 error as ORA-12504
(4111095552) [17-APR-2019 22:13:40:055] niqme: exit
(4111095552) [17-APR-2019 22:13:40:055] niotns: Couldn't connect, returning 12504
CAUSE
It is necessary to EITHER include the password on the same line OR to escape the EZCONNECT string and supply the password on the subsequent line.