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

ORA-12154: TNS could not resolve the connect identifier specified error comes when you try to connect Oracle database using clients/tools like SQL Plus, Toad, Oracle Forms, Oracle Reports, and SQL*Net could not find the alias specified for a connection in the TNSNAMES.ORA file or other naming adapters.

Now, let’s reproduce the error and find out solution for ora 12154. We are going to us Oracle Forms 11G on the Oracle Web logic server for demonstration.

Reproduce ORA-12154

Open the Oracle form builder and connect it to the database. Create a custom form. Compile the form and then start the web logic server. Run the form.

Internet Explorer (IE) opens and launches the form service, but you get the error as shown below,

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

What is wrong here?

The form builder is able to connect to the database during design time what happens when you run the form.

Let me explains,

ORA 12154 Solution

Form builder uses default.env file during run time and TNS_ADMIN variable to locate the tnsnames.ora file. Below is the value of this variable.

TNS_ADMIN – C:\Oracle\Middleware\asinst_1\config

So copy the tnsnames.ora file to the location specified by the TNS_ADMIN variable to resolve ORA 12154 error in Oracle forms. If this does not work, just comment the TNS_ADMIN variable entry in default.env file as shown below and copy tnsnames.ora file to ORACLE_HOME path.

ORACLE_HOME=C:\Oracle\Middleware\Oracle_FRHome1

Then run the forms, your forms should work fine.

Still facing the issue, it means something wrong with TNS entries.

Verify TNSNAMES.ORA and SQLNET.ORA files

First, verify tnsnames.ora and sqlnet.ora file exists in ORACLE_HOME and there is a proper entry of the database which you are trying to connect.

Below is the default location for tnsnames.ora and sqlnet.ora files for Windows and Linux /Unix Operating System.

Windows Client

ORACLE_HOME\network\admin

UNIX Client

$ORACLE_HOME/NETWORK/ADMIN
or /etc
or /var/opt/oracle

Sample TNS entry,

TEST =
     (DESCRIPTION =
       (ADDRESS_LIST =
           (ADDRESS =
             (PROTOCOL = TCP)
             (Host = xxx.yy.zz.56)
             (Port = 1521)
           )
       )
       (CONNECT_DATA = (SERVICE_NAME = TEST)
       )
     )

Sample SQLNET.ora entry,

TRACE_LEVEL_CLIENT = OFF
SQLNET.AUTHENTICATION_SERVICES = (NONE)
NAMES.DIRECTORY_PATH = (TNSNAMES)

Summary

I am sure solution mentioned in this article should help you to resolve this TNS 12154 error. If you still facing issue and not able to resolve, I would recommend to read below articles.