Oracle Database - Connect String (Client Connection Initiation)

1 - 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.

3 - Syntax: Connecting to a Database

3.1 - From the command line

tool [email protected]_identifier
Enter password: password

Example with SQLPlus on a shell

sqlplus username/[email protected]_identifier

3.2 - From within SQL*Plus

In SqlPlus with the CONNECT command:

CONNECT username/password@connect_identifier

3.3 - From a login screen

username/password@connect_identifier

3.4 - 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.

4 - Connect string example with as the connect identifier

4.1 - a complete connect descriptor

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

4.2 - a net service name

CONNECT scott/tiger@sales

5 - 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.
db/oracle/connect_string.txt ยท Last modified: 2017/09/06 19:27 by gerardnico