Table of Contents

Oracle Database - Connect Descriptor (TNS Connect String)

About

The Connect Descriptor (known also as TNS Connect String) is a type of connect identifier. It defines the parameters that need the Oracle Net Service to connect to a database service :

You can gives a connect descriptor:

Syntax

A connect descriptor is comprised of one or more protocol addresses of the listener and the connect information for the destination service.

(DESCRIPTION= 
  (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521)) 
  (CONNECT_DATA= 
     (SID=sales)
     (SERVICE_NAME=sales.us.example.com)
     (INSTANCE_NAME=sales))
     (SERVER=shared)))
)

where

Database connection type

If shared server is configured in the initialization parameter file, you can select Dedicated Server to force the listener to spawn a dedicated server, bypassing shared server configuration. If shared server is configured in the initialization parameter file and you want to guarantee the connection always uses shared server, select Shared Server.

Enhancing Service Accessibility using Multiple Listeners

For some configurations, such as Oracle Real Application Clusters, multiple listeners on multiple nodes can be configured to handle client connection requests for the same database service. In the following example, sales.us.example.com can connect using listeners on either sales1-server or sales2-server.

(DESCRIPTION=
  (ADDRESS_LIST=
    (ADDRESS=(PROTOCOL=tcp)(HOST=sales1-server)(PORT=1521))
    (ADDRESS=(PROTOCOL=tcp)(HOST=sales2-server)(PORT=1521)))
  (CONNECT_DATA=
    (SERVICE_NAME=sales.us.example.com)))

A multiple-listener configuration also enables you to leverage the failover and load balancing features, either individually or in combination with each other. The following topics describe the features:

More … Enhancing Service Accessibility using Multiple Listeners

How to get the TNS connect string ?

You can get the connect string by performing a tnsping on the tnsname.

C:\Documents and Settings\Nicolas>tnsping orcl

TNS Ping Utility for 32-bit Windows: Version 10.2.0.4.0 - Production on 10-JUN-2009 11:09:18

Copyright (c) 1997,  2007, Oracle.  All rights reserved.

Used parameter files:
C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ngerard)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED
) (SID = orcl)))
OK (80 msec)

C:\Documents and Settings\Nicolas>tnsping qsdb > c:\tns.txt

You can then retrieve the TNS Connect Descriptor from the file tns.txt of from the screen. The TNS Connect string is :

(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ngerard)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = QSDB)))