8.4.1 Understanding the Easy Connect Naming Method

The Easy Connect naming method provides out-of-the-box TCP/IP connectivity to databases.

Overview

This naming method extends the functionality of the host naming method by enabling clients to connect to a database server with an optional port and service name in addition to the host name of the database:


CONNECT username@[//]host[:port][/[service_name][:server_type][/instance_name]]
Enter password: password

The connect identifier converts to the following connect descriptor:

(DESCRIPTION= 
  (ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=port))
  (CONNECT_DATA=
    (SERVICE_NAME=service_name)
    (SERVER=server_type)
    (INSTANCE_NAME=instance_name))
)

If the Oracle Database server installation was performed in Typical mode, then the default service name used by the Oracle instance is the database name, and the following Easy Connect syntax can be used to connect to that instance:

SQLPLUS /nolog
SQL> CONNECT username@host/db_name
SQL> Enter password: password

Easy Connect Syntax Examples

The connect strings in the following example connect the client to database service sales.us.example.com with a listening endpoint of 1521 on database server sales-server:
CONNECT scott@sales-server:1521/sales.us.example.com
CONNECT scott@//sales-server/sales.us.example.com
CONNECT scott@//sales-server.us.example.com/sales.us.example.com

After each of the connect strings, you must enter a password to connect to the database service.

These connect strings convert into the following connect descriptor:
(DESCRIPTION= 
  (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521))
  (CONNECT_DATA=
    (SERVICE_NAME=sales.us.example.com)))

Connect Identifier for Easy Connect Naming

This is a list of the Easy Connect syntax elements and descriptions for each:

Syntax Element Description

//

Use // to specify a URL or JDBC connection.

Required for URL or JDBC connections. The connect identifier must be preceded by a double-slash (//). For example:

scott@//sales-server
Enter password: password

Optional for SQL connections. The connect identifier can preceded by a double-slash (//). For example, the following connect strings are semantically equivalent:

SQL> CONNECT scott@sales-server
SQL> CONNECT scott@//sales-server

host

Required. Specify the host name or IP address of the database host computer.

The host name is domain-qualified if the local operating system configuration specifies a domain.

You may use an IPv4 or IPv6 address as a value. IPv6 addresses or host names that resolve to IPv6 addresses must be enclosed in square brackets, as in [2001:0db8:0:0::200C:417A] and [salesdb].

port

Optional. Specify the listening port.

The default is 1521.

service_name

Optional. Specify the service name of the database.

If a user specifies a service name, then the listener connects the user to that specific database. Otherwise, the listener connects to the database specified by the DEFAULT_SERVICE_listener_name parameter in the listener.ora file. If DEFAULT_SERVICE_listener_name is not configured for the listener and a service name is not explicitly specified by the user as part of the Easy Connect syntax, then the listener returns an error.

server_type

Optional. Specify the database server type to use.

This parameter instructs the listener to connect the client to a specific type of service handler.

The values for the server_type parameter are dedicated, shared, and pooled. If server is not specified in the Easy Connect syntax, then the type of server is chosen by the listener (shared server if configured, otherwise a dedicated server is used).

Note: In Oracle Call Interface documentation, server is referred to as connect_type.

instance_name

Optional. Identify the database instance to access.

The instance name can be obtained from the INSTANCE_NAME parameter in the initialization parameter file.