Fixing the Oracle Connection Error: ORA-12154

Fixing the Oracle Connection Error: ORA-12154

Fixing the Oracle Connection Error: ORA-12154: TNS:could not resolve the connect identifier specified

To fix this error when connecting to an Oracle database, follow the steps below:


1. Create the tnsnames.ora file

Create a file named tnsnames.ora with the following content:

REALDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = YOUR_IP_OR_HOST)(PORT = YOUR_PORT))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = YOUR_SERVICE_NAME)
    )
  )

Warning
Replace YOUR_IP_OR_HOST, YOUR_PORT, and YOUR_SERVICE_NAME with the actual connection details.


2. Save it to the correct directory

Save the file to the following path:

C:\instantclient_19_6\network\admin

WarningIf the network and admin folders do not exist, create them manually.

3. Set environment variables in Windows

Go to:
Control Panel → System → Advanced system settings → Environment Variables

Add or edit the following System Variables:


Add or edit the following environment variables:

  • TNS_ADMIN
    Name: TNS_ADMIN
    Value C:\instantclient_19_6\network\admin

  • ORACLE_HOME
    Name: ORACLE_HOME
    Vakue: C:\instantclient_19_6


4. Edit the Apache configuration

Open the file:

C:\Program Files\NetMake\v9-php81\components\apache\conf\httpd.conf 

Add the following lines:

FcgidInitialEnv TNS_ADMIN "C:/instantclient_19_6/network/admin"

FcgidInitialEnv ORACLE_HOME "C:/instantclient_19_6"

These lines should be inserted between the FcgidMaxRequestLen and Timeout directives.

5. Apply the environment setup

  • Save the httpd.conf file after adding the FcgidInitialEnv variables.

  • Restart your computer so the environment variables (TNS_ADMIN and ORACLE_HOME) are correctly applied.


6. Create the connection in Scriptcase

  • pen Scriptcase and go to the database connection creation screen.

  • Select the desired Oracle driver.

  • In the "Database" field, enter the name defined in the tnsnames.ora file (e.g., REALDB).

If everything is configured correctly, the connection to the Oracle database will be established successfully.

    • Related Articles

    • Filtering Connection Database - Oracle

      On various occasions, we encounter slowness when connecting to the database or while editing and executing applications. It is possible to resolve these issues by optimizing data loading through filter configuration. To do so, follow these steps: ...
    • Installing Scriptcase with PHP 7.3 on Windows

      This documentation will walk you through the steps necessary to install PHP 7.3, Apache 2.4, and Scriptcase manually. When performing this type of installation, you are responsible for configuring your entire environment as well as database ...
    • Oracle Connection - Scriptcase 9 - Linux 64 Bits

      This procedure will only work if you have a Scriptcase manual installation in your server. Installing PHP 7.0 Installing the Scriptcase Manually To connect with Oracle in a Linux System, we must follow these steps below: Step 1 -  Installing these ...
    • Scriptcase Installer for Windows - PHP 7.3

      The Scriptcase installer installs Apache, PHP, and Scriptcase on your operating system. The installer does not include a database. Prerequisites To download the Scriptcase Installer, go to our download page clicking here. Listed below are all the ...
    • Oracle Connection - Scriptcase 8.1 - Linux

      To enable the connection to Oracle on Linux, we must perform the following steps: Prerequisites Step 1  -  Add the i386 architecture and install the packages below : UBUNTU\DEBIAN CENTOS\RHEL - sudo dpkg —add-architecture i386 
- sudo apt-get update
 ...