2.5 Understanding Naming Methods

Oracle Net Services offers several types of naming methods that support localized configuration on each client, or centralized configuration that can be accessed by all clients in the network.

2.5.1 About Naming Methods

A naming method is a resolution method used by a client application to resolve a connect identifier to a connect descriptor when attempting to connect to a database service.

Overview

The information needed to use a service name to create a database connection can be stored in a repository, which is represented by one or more naming methods. Users initiate a connection request by providing a connect string.

A connect string includes a user name and password, along with a connect identifier. A connect identifier can be the connect descriptor or a name that resolves to a connect descriptor. The connect descriptor contains:

  • Network route to the service, including the location of the listener through a protocol address

  • A database service name or Oracle system identifier (SID)

The following CONNECT command uses a connect string that has a complete connect descriptor as the connect identifier instead of a network service name. The string should be entered on a single line. It is shown on two lines because of page width.

SQL> CONNECT hr@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server1)
(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=sales.us.example.com)))

One of the most common connect identifiers is a network service name, a simple name for a service. The following CONNECT command uses a connect string that uses network service name sales as the connect identifier:

SQL> CONNECT hr@sales

When network service name sales is used, connection processing takes place by first mapping sales to the connect descriptor.

Types of Naming Methods

The mapped information is accessed by naming methods. The following naming methods are available:

  • Local Naming

  • Directory Naming

  • Centralized Configuration Provider Naming

  • Easy Connect Naming

How to Configure Naming Methods

A naming method configuration consists of the following steps:
  1. Select a naming method.

  2. Map connect descriptors to the names or to a connect identifier.

  3. Configure clients to use the naming method.

2.5.2 Choosing a Naming Method

Selecting the appropriate naming method for mapping names to connect descriptors depends upon the size of the organization.

  • For a small organization with only a few databases, use Easy Connect Naming to make TCP/IP connections with the host name of the database server or local naming to store names in tnsnames.ora file on the clients.

  • For large organizations with several databases, use Directory Naming to store names in a centralized directory server or Centralized Configuration Provider Naming to store names in a Centralized Configuration Provider.

  • For an Internet network, configure the application web servers needed to connect to the databases with the Local Naming method.

This is a summary of the advantages and disadvantages of each naming method, and some recommendations for using them in the network:

Naming Method Description Advantages/Disadvantages Recommended for:

Local Naming

Stores network service names and their connect descriptors in a localized configuration file named tnsnames.ora, which by default is located in the ORACLE_BASE_HOME/network/admin directory.

Advantages:

  • Provides a straightforward method for resolving network service name addresses.

  • Resolves network service names across networks running different protocols.

Disadvantage: Requires local configuration of all network service name and address changes.

Simple distributed networks with a small number of services that change infrequently.

Directory Naming

Stores connect identifiers in a centralized LDAP-compliant directory server to access a database service.

Advantages:

  • Centralizes network names and addresses in a single place, facilitating administration of name changes and updates. This eliminates the need for an administrator to make changes to what potentially could be hundreds or even thousands of clients.

  • Directory stores names for other services.

  • Tools provide simple configuration.

  • Provides an alternative method to specify LDAP name lookup by passing LDAP parameters directly in the connect identifier, instead of specifying external configuration files (such as ldap.ora and sqlnet.ora).

Disadvantage: Requires access to a directory server.

Large, complex networks (with over 20 client computers) that change on a frequent basis.

Centralized Configuration Provider Naming

Stores connect descriptors and optionally database credential references in a Centralized Configuration Provider, such as Azure App Configuration store or Oracle Cloud Infrastructure (OCI) Object Storage as a JSON file.

Advantages:

  • Centralizes network names and addresses in a single location, facilitating administration (addition, deletion, or modification) of connect descriptors. This eliminates the need for an administrator to change multiple client connect descriptors, which potentially could be hundreds or even thousands in number.

    For example, if a large number of connect descriptors are stored on a client using the Local Naming method (tnsnames.ora) or Easy Connect Naming method, then any modification would require an update to all those client connect descriptors.

  • If you are using the instance based or managed identity based authentication, then the password to access the Centralized Configuration Provider is managed by Microsoft Azure or OCI.

  • Enables you to centrally manage database password change policies for all stored database user names and database passwords.

  • Enables client applications running on multitenant cloud service environments (which may not have access to wallet stored in local system file) to centrally manage wallets in remote stores.

Disadvantages:

  • Requires access to the OCI Object Storage or Azure App Configuration service.

  • When used outside the instance-based or resource principal or managed identity-based authentication, might need you to modify cloud access user name and password in the connect identifier whenever there is a change in them.

Large, complex networks (with over 20 client computers) that change on a frequent basis.

Easy Connect Naming

Enables clients to connect to an Oracle database server by using a TCP/IP connect string consisting of a host name and optional port and service name.

Advantages:

  • Requires minimal user configuration. The user can provide only the name of the database host to establish a connection.

  • The Easy Connect Naming method requires no client-side configuration.

  • Eliminates the need to create and maintain a local names configuration file (tnsnames.ora).

Disadvantage: Available only in a limited environment, as indicated in the Recommended for column.

Simple TCP/IP networks that meet the following criteria:

  • The client and server are connecting using TCP/IP.

  • No features requiring a more advanced connect descriptor are required.

2.5.3 Establishing a Client Session Using a Naming Method

Learn about a typical process for establishing a client session using a naming method.

  1. The client initiates a connect request by providing a connect identifier.

  2. The connect identifier is resolved to a connect descriptor by a naming method.

  3. The client makes the connection request to the address provided in the connect descriptor.

  4. A listener receives the request and directs it to the appropriate database server.

  5. The connection is accepted by the database server.

Note:

Besides connect descriptors, you can use naming methods to map a connect name to a protocol address or protocol address list.

2.5.4 Entering a Connection String

You can make a connection across the network after the network components are started. How you make a connection depends upon the naming method and the tool used for the connection.

The connection string (or connect string) takes the following format:
CONNECT username@connect_identifier

Default Connect Identifier

On most operating systems, you can define a default connect identifier. When using the default, a connect identifier does not need to be specified in the connect string. To define a default connect identifier, use the TWO_TASK environment variable on Linux and UNIX platforms or the LOCAL environment variable or registry entry on Microsoft Windows.

For example, if the TWO_TASK environment variable is set to sales, then you can connect to a database from SQL*Plus with CONNECT username rather than CONNECT username@sales. Oracle Net checks the TWO_TASK variable, and uses the value sales as the connect identifier.

For instructions on setting the TWO_TASK and LOCAL environment variables, see the Oracle operating system-specific documentation.

Connect Identifier and Connect Descriptor Syntax Characteristics

Connect identifiers used in a connect string cannot contain spaces, unless enclosed within single quotation marks (') or double quotation marks ("). In the following examples, a connect identifier and a connect descriptor that contain spaces are enclosed within single quotation marks:
CONNECT scott@'(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)
(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=sales.us.example.com)))'
Enter password: password

CONNECT scott@'cn=sales, cn=OracleContext, dc=us, dc=example, dc=com'
Enter password: password
Single quotation marks are required if double quotation marks are used in a connect identifier. For example:
CONNECT scott@'sales@"good"example.com'
Enter password: password
Similarly, double quotation marks are required if single quotation marks are used in a connect identifier. For example:
CONNECT scott@"cn=sales, cn=OracleContext, ou=Mary's Dept, o=example"
Enter password: password

Oracle Database Connection String Utility

Starting with Oracle Database 23ai, you can use the Oracle Database Connection String command-line utility (connstr) to display connect strings for all the available network service names.

You can display these strings in various formats (such as Easy Connect, JDBC Thin, or connect descriptor) and use in client applications or tools (such as SQL*Plus, Python, or JDBC Thin clients) to quickly connect to the database. In addition, the connstr utility enables you to write service names and their connect descriptors in the tnsnames.ora file for use with the local naming method.

For example, the utility generates a tnsnames.ora file that contains the following connect descriptor for the sales.us.example.com service name:

sales.us.example.com=
    (DESCRIPTION=
        (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521))
        (CONNECT_DATA=
            (SERVICE_NAME=sales.us.example.com))
    )

The client application can use sales.us.example.com in the connect string to connect to the database, as follows:

sqlplus scott@sales.us.example.com
Enter password: password