Oracle Database - Connect String (Client Connection Initiation)
Table of Contents
1 - About
Users initiate a connection request to a database service by providing a connect string.
A connect string includes:
- a username and password,
- along with a connect identifier.
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.
2 - Articles Related
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:
3.3 - From a login screen
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
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:
- The client initiates a connect request by providing a connect identifier.
- The connect identifier is resolved to a connect descriptor by a naming method. This information is returned to the client.
- 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.