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.
- 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. - Choosing a Naming Method
Selecting the appropriate naming method for mapping names to connect descriptors depends upon the size of the organization. - Establishing a Client Session Using a Naming Method
Learn about a typical process for establishing a client session using a naming method. - 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.
Parent topic: Identifying and Accessing the Database
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
-
Select a naming method.
-
Map connect descriptors to the names or to a connect identifier.
-
Configure clients to use the naming method.
Related Topics
Parent topic: Understanding Naming Methods
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 |
Advantages:
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:
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:
Disadvantages:
|
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:
Disadvantage: Available only in a limited environment, as indicated in the Recommended for column. |
Simple TCP/IP networks that meet the following criteria:
|
Related Topics
Parent topic: Understanding Naming Methods
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.
-
The client initiates a connect request by providing a connect identifier.
-
The connect identifier is resolved to a connect descriptor by a naming method.
-
The client makes the connection request to the address provided in the connect descriptor.
-
A listener receives the request and directs it to the appropriate database server.
-
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.
Parent topic: Understanding Naming Methods
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.
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
'
) 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
CONNECT scott@'sales@"good"example.com'
Enter password: password
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
Related Topics
Parent topic: Understanding Naming Methods