The error also appears in some versions as: “ORA-12154: TNS:could not resolve service name.”
When a program needs to connect to an Oracle service via Oracle Networking (SQL*Net), it must look up the connect data for that service somewhere. When the lookup fails, the Oracle client code raises ORA-12154. Most people will encounter this error when their application tries to connect to an Oracle database service, but it can also be raised by one database instance trying to connect to another database service via a database link.
Note that this error is generated by the Oracle client code on the local host where the program is running, not by the remote Oracle service to which you are attempting to connect.
There are a few ways that the Oracle client code can look up connect data:
- A flat file named tnsnames.ora
- Oracle Names service
If you see the whole ORA-12154 error with the text, then your program is finding a working Oracle client install, but that the Oracle service as specified is not listed in tnsnames.ora, Oracle Names or LDAP. The most common causes of ORA-12154 are:
- The entry is missing from tnsnames.ora
- The entry in tnsnames.ora is malformed
- The program is using tnsnames.ora from the wrong ORACLE_HOME
- The program is not using a fully-qualified service name, but no default domain is enabled in sqlnet.ora
Most sites use tnsnames.ora, but enough use Oracle Names and LDAP that the first step should be to determine which name resolution method is deployed at your site. If you are not the database administrator, you should get in touch with the people who manage your Oracle systems and find out which method you should be using. Often they will be able to provide guidance for resolving your problem in accordance with your site’s standards.
The client code decides which mechanism to use based on the file sqlnet.ora. This and tnsnames can usually both be found in the Oracle install directory (“ORACLE_HOME”), under network/admin/. This location may be overridden with the environment variable TNS_ADMIN. If the sqlnet.ora file does not exist, or does not specify a resolution method, then Oracle Net uses tnsnames.ora.
Example locations of Oracle networking files:
ORANTNET80ADMIN ORACLEORA81NETWORKADMIN ORAWIN95NETWORKADMIN ORAWINNETWORKADMIN
UNIX / Linux:
$ORACLE_HOME/network/admin/ /etc/ /var/opt/oracle/
EPM applications help measure the business performance. This post will help you choose the best EPM solutions for your organization’s needs and objectives.
Ready to migrate your MySQL database to Amazon Web Services (AWS)? Which is better, Amazon RDS or Amazon EC2? Learn the pros and cons of each option.