Oracle7 Server Distributed Systems Volume I: Distributed Data

Contents Index Home Previous Next

Initiating a SQL*Net Connection

There are a number of ways to initiate a connection with an Oracle server. Commonly used methods are:

The specifics of use are slightly different in each case. Each of the general methods listed is briefly covered here. To identify the method used by a specific utility, see that utility's user's guide.

Connecting from the Operating-System Command Line

The general form of connecting an application to a database server from the command line is:

tool username/password@service_name 

where:

tool Specifies the command used to invoke a utility such as SQL*Plus, SQL*DBA, SQL*Forms, etc.
username Specifies an Oracle username on the server.
password Specifies the corresponding password on the server.
service_name Specifies a service name entered in Oracle Names or the TNSNAMES.ORA file that identifies the connect descriptor for the desired server. If the server is in the client's default domain, the service name does not need to include the domain name. However, if the server is in another domain, the service name must include the domain. (The default domain is determined by a parameter in the client's SQLNET.ORA file.
For example, in a network with only one domain, the default .WORLD domain, it is not necessary to include ".WORLD" in the service name. For example:

				% sqlplus scott/tiger@SERVERX

However, if the client's default domain were .EAST and the server's domain were .WEST, then the service name would have to include the domain. For example,

				% sqlplus scott/tiger@SERVERX.WEST

Note: To prevent a password from displaying during a logon, you can omit the password parameter on the command line. You will then be prompted to enter your password. It will not be displayed as you enter it

Most Oracle utilities can use the operating-system command line to connect. Others provide alternatives.

Connecting from the Utility Logon Screen

Some utilities provide a logon screen as an alternative form of logon. A user can log on to a database server just as easily by identifying both the username and service name in the username field of the utility logon screen, and typing the password as usual in the password field. Figure 3 - 6 shows a SQL*Forms logon screen where the user SCOTT is connecting to the server SERVERX with a password of TIGER. Notice the password cannot be seen, a standard feature of Oracle utilities' logon screens.

Figure 3 - 6. Connection from Logon Screen

Connecting from a 3GL Application

In applications written using a 3GL, the program must establish a connection to a server using the following syntax:

EXEC SQL CONNECT :username IDENTIFIED BY :password 

In this connection request, the :username and :password are 3GL variables that can be set within the program either statically or by prompting the user. When connecting to a database server, the value of the :username variable is in the form:

username@service_name 

which is the same as in the logon screen above. The :password variable contains the password for the database account being connected to.

Connecting Using Special Commands within Utilities

Some Oracle utilities have internal commands for database connection, once the utility has been started, that allow an alternative username to be specified without leaving the utility. Both SQL*Plus and SQL*DBA allow the CONNECT command using the following syntax:

SQL> CONNECT username/password@service_name 

For example:

SQL> CONNECT SCOTT/TIGER@SERVERX 

This is very similar to the operating-system command-line method, except that it is entered in response to the utility's prompt instead of the operating-system prompt.

Other Oracle utilities use slightly different methods specific to their function or interface. For example, Oracle CDE utilities use logon buttons and a pop-up window with the username, password, and remote database ID field. For more information on connecting to Oracle with a specific utility, see that utility's user guide.


Contents Index Home Previous Next