16.3.2 ORA-12154

Indicates that the specified connection alias cannot be resolved.

Message

ORA-12154: Cannot connect to database.
Could not find alias string in string.

For example:

With the LDAP naming adapter:
ORA-12154: Cannot connect to database.
Could not find alias sales in LDAP.
With the TNSNAMES naming adapter:
  • When only one (system or local) tnsnames.ora file is used:
    ORA-12154: Cannot connect to database.
    Could not find alias sales in
        /u01/app/oracle/product/21.3.0/dbhome_1/network/admin/tnsnames.ora.
  • When both the system and local tnsnames.ora files are used:
    ORA-12154: Cannot connect to database.
    Could not find alias sales in
        path_to_file_1, path_to_file_2.
With the TNSNAMES and LDAP naming adapters:
  • When only one (system or local) tnsnames.ora file is used:
    ORA-12154: Cannot connect to database.
    Could not find alias sales in
        /u01/app/oracle/product/21.3.0/dbhome_1/network/admin/tnsnames.ora and LDAP.
  • When both the system and local tnsnames.ora files are used:
    ORA-12154: Cannot connect to database.
    Could not find alias sales in
        path_to_file_1, path_to_file_2 and LDAP.

Cause

A connection to the database or other service is requested using a connection alias, but the specified alias cannot be resolved into a connect descriptor using one of the configured naming methods. For example, if you have used a network service name as the connect identifier, then the network service name cannot be found in a naming method repository or the repository cannot be located.

By default, the client tries all naming methods in an order: starting with local (TNSNAMES), followed by LDAP, and then Easy Connect Plus. A failure to resolve an alias through all of these naming methods returns in an error.

Action

  1. Check for mistakes in the specified connection string.

  2. If your sqlnet.ora file contains the NAMES.DIRECTORY_PATH parameter, then ensure that the parameter contains valid values.

  3. If you are using an alias from the tnsnames.ora file, then perform these steps:
    • Verify that the tnsnames.ora file exists, is in the correct directory, and is accessible. You can find the tnsnames.ora file in any of the following locations:
      • The directory specified by the TNS_ADMIN environment variable, if it is set.

      • The ORACLE_BASE_HOME/network/admin directory. If the file is not present in the ORACLE_BASE_HOME/network/admin directory, then look for the file in ORACLE_HOME/network/admin directory.

    • Ensure that the alias, given in the connect string, exists in one of the tnsnames.ora files.

      This network service name should match the name in the tnsnames.ora file exactly if the name is simple and there is not NAMES_DEFAULT_DOMAIN in the sqlnet.ora file, or the network service name is a fully-qualified name. If the network service name in the connect string is simple, then check the NAMES_DEFAULT_DOMAIN parameter in the sqlnet.ora file. Its value is appended to the network service name given in the connect string. This fully-qualified name should be the entry in the tnsnames.ora file.

    • Ensure that there are no syntax errors anywhere in the tnsnames.ora files. Look for unmatched parentheses or stray characters. Ensure that magic quotes are not used.

    • If you are connecting from a Login dialog box, then verify that you are not placing an at sign (@) before the connect network service name. Activate client tracing, and repeat the operation.

  4. If you are using LDAP directory naming, then perform these steps:
    • Verify that the net service name or database name used as the connect identifier is configured in the directory.

    • Verify that the LDAP directory server is up and accessible.

    • Verify that the default context used is correct by specifying a fully-qualified net service name or a full LDAP DN as the connect identifier.

    • Verify that the ldap.ora file exists and is in the correct location. The following directories are searched for the ldap.ora file in an order:
      • The directory specified by the TNS_ADMIN environment variable.

      • The ORACLE_BASE_HOME/network/admin directory. If the file is not present in the ORACLE_BASE_HOME/network/admin directory, then the file is searched in the ORACLE_HOME/network/admin directory.

      • The directory specified by the LDAP_ADMIN environment variable.

      • The ORACLE_BASE_HOME/network/admin directory for a read-only Oracle home.

      • The ORACLE_HOME/network/admin directory for a read/write Oracle home.

    • Verify that the parameters defined in the ldap.ora file are correct, as follows:
      • The DIRECTORY_SERVERS parameter defines the correct host and port for one or more valid LDAP servers.

      • The DEFAULT_ADMIN_CONTEXT parameter defines the location of the Oracle Context in this directory that should include the network service entry.

      If the ldap.ora file does not exist, then these parameters are resolved using automatic discovery.

    • Verify that the LDAP server host and port are defined in DNS.

    • Verify that the directory has the default Oracle Context defined.

    • Use the ldapsearch utility or a directory administration tool to verify that the network service object exists in the Oracle Context at the location given by the value of the DEFAULT_ADMIN_CONTEXT parameter.