7 The Oracle Data Provider : Connecting Using a tnsnames.ora File

Connecting Using a tnsnames.ora File
The Oracle data provider allows you to use information from an existing Oracle tnsnames.ora file to connect. Using an Oracle tnsnames.ora file to centralize connection information in your Oracle environment simplifies maintenance when changes occur. The DataDirect Connect for ADO.NET Oracle data provider does not require the Oracle client. However, some users already have the client installed on their machines and have a tnsnames.ora file configured.
To use the connection information in an Oracle tnsnames.ora file, you specify the TNSNames File and Data Source properties instead of the following Oracle data provider connection string options:
The TNSNames File connection string option specifies the fully qualified path to the tnsnames.ora file. The Data Source connection string option specifies the net service name entry within the tnsnames.ora file that references that connection information.
For information about configuring your tnsnames.ora file, refer to your Oracle documentation.
Defining Multiple tnsnames.ora Files
To specify multiple tnsnames.ora files, separate each tnsnames.ora file name with a comma and enclose the entire value of the tnsnames.ora file in parentheses, for example:
"TNSNames File=(F:\server2\oracle\tnsnames.ora, C:\oracle\product\10.1.0\db_1\network\admin\tnsnames.ora)"
The data provider tries to open the first file in the list. If that file is not available, then the data provider tries to open the second file in the list, and so on.
Defining Multiple Attempts to Access a tnsnames.ora File
You can provide retry information for the tnsnames.ora file if the file is unavailable, for example, because of a hardware failure or traffic overload. To set this feature, use the Connection Retry Count connection string option to define the number of times the data provider attempts to access the tnsnames.ora file after the initial attempt. By default, the data provider does not retry.
You can also define the wait interval, in seconds, used between attempts to access the tnsnames.ora file. The default interval is 3 seconds. To set this feature, use the Connection Retry Delay connection string option.
tnsnames.ora File Example
In a tnsnames.ora file, connection information for Oracle services is associated with a net service name. The following code example shows connection information in a tnsnames.ora file configured for an Oracle RAC system identified by the net service name entry, ARMSTRONG.ACCT.
ARMSTRONG.ACCT =
   (DESCRIPTION =
     (ADDRESS_LIST=
     (ADDRESS= (PROTOCOL = TCP)(HOST = server1)(PORT = 1521))
     (ADDRESS= (PROTOCOL = TCP)(HOST = server2)(PORT = 1521))
     (ADDRESS= (PROTOCOL = TCP)(HOST = server3)(PORT = 1521))
     (FAILOVER = on)
     (LOAD_BALANCE = on)
     )
     (CONNECT_DATA=
       (SERVICE_NAME = acct.us.yourcompany.com)
     )
   )
If the Oracle data provider referenced the net service name entry ARMSTRONG.ACCT as shown in this example, the data provider would connect to the Oracle RAC system identified by the service name acct.us.yourcompany.com (SERVICE_NAME=acct.us.yourcompany.com). In addition, the data provider would enable connection failover (FAILOVER=on) and client load balancing (LOAD_BALANCE=on) for all connections to that system.
Alternatively, DataDirect Connect for ADO.NET provides a programmatic way to enable connection failover and client load balancing through options specified in the data provider connection string. For example, the following connection string enables both of these features:
Conn.ConnectionString = "Host=server1;Port=1521;Service Name=ORCL; Alternate Servers="Host=server2;Port=1521;Service Name = TEST, Host=255.210.11.25;Port=1600;Service Name = TEST2";Load Balancing=True";