About

Users initiate a connection request to a database service by providing a connect string.

A connect string includes:

A connect identifier can be the connect descriptor itself or a name that resolves to a connect descriptor.

One of the most common connect identifiers is a net service name, a simple name for a service. The following examples demonstrate one connect string that uses a complete connect descriptor as the connect identifier and another connect string that uses net service name sales as the connect identifier.

Syntax: Connecting to a Database

From the command line

tool username@connect_identifier
Enter password: password

Example with SQLPlus on a shell

sqlplus username/password@connect_identifier

From within SQL*Plus

In SqlPlus with the CONNECT command:

CONNECT username/password@connect_identifier

From a login screen

username/password@connect_identifier

From a 3GL application

Applications written in 3GL, such as oci and pre-compilers, are used by middle-tier and database application developers for direct database access from a client program.

exec sql connect :username identified by :password 

In the preceding connection request, :username and :password are 3GL variables that can be set within the program either statically or by prompting the user.

Connect string example with as the connect identifier

a complete connect descriptor

CONNECT scott/tiger@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server1)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=sales.us.acme.com)))

a net service name

CONNECT scott/tiger@sales

Connection Process

When net service name is used, connection processing takes place by first mapping sales to the connect descriptor. This mapped information is stored in one or more repositories of information that are accessed with naming methods.

The process for establishing a client session with the aid of a naming method is as follows:

  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. This information is returned to the client.
  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.