ORA-12154 – TNS:could not resolve the connect identifier specified
Today I try to connect to one Db service named pditui using the following easy connect method:
sqlplus "sys/password@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = scanname.test.example.com)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = pditui)))" as sysdba
However, the following error messages prompted:
SQL*Plus: Release 184.108.40.206.0 Production on Tue Dec 2 14:07:35 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
ORA-12154: TNS:could not resolve the connect identifier specified
ORA-12162: TNS:net service name is incorrectly specified
The username/password and service name were all correct, but the error was there. After some checking, I found that it was caused by wrong configuration of NAMES.DIRECTORY_PATH in file $ORACLE_HOME/network/admin/sqlnet.ora:
[root@centos-doxer ~]# cat /u01/app/oracle/product/11.2.0/client_1/network/admin/sqlnet.ora
# sqlnet.ora Network Configuration File: /u01/app/oracle/product/11.2.0/client_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DIRECTORY_PATH= (TNSNAMES,ezconnect) -- add ezconnect methond here
ADR_BASE = /u01/app/oracle
After this, the connection was ok.
You can read more about NAMES.DIRECTORY_PATH in file $ORACLE_HOME/network/admin/sqlnet.ora here.