Understanding SQL*Net

Contents Glossary 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 in a specific tool, refer to the tool'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 

In this syntax:

tool Specifies the command used to invoke a tool such as SQL*Plus, 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 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. See the section on the SQLNET.ORA file in Appendix A of this manual.)
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 the password from displaying during a logon, you can leave out the password parameter on the command line; you will then be prompted to enter your password without it showing on screen.

Most Oracle tools can use the operating system command line to connect; some provide alternatives.

Connecting from the Tool Logon Screen

Some tools 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 tool logon screen, and typing the password as usual in the password field. Figure 5 - 1 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 tool logon screens.

Figure 5 - 1. 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 tool logon screen above. The :password variable contains the password for the database account being connected to.

Connecting Using Special Commands within Tools

Some Oracle tools have commands for database connection, once the tool has been started, to allow an alternative username to be specified without leaving the tool. 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 tool prompt instead of the operating system prompt.

Other Oracle tools use slightly different methods specific to their function or interface. For example, Oracle CDE tools 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 tool, refer to the tool's user guide.


Contents Glossary Index Home Previous Next