ORA-12154: TNS could not resolve the connect identifier specified error comes when you try to connect to 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 the solution for Ora 12154. We are going to use 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,
What is wrong here?
The form builder is able to connect to the database during design time which happens when you run the form.
Let me explain,
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 the ORA 12154 error in Oracle forms. If this does not work, just comment the TNS_ADMIN variable entry in the 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 to 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 the solution mentioned in this article should help you to resolve this TNS 12154 error. If you still facing issues and are not able to resolve them, I would recommend reading the below articles.
- ORA-12154-TNS Could not Resolve the Connect identifier Specificed when Connecting from Forms Builder (Doc ID 1604843.1)
- TNS Issues when connecting to database with Forms Builder 12.2.1.2.0