Note: If using a tnsnames.ora file to retrieve connection information, you cannot specify some of the connection properties described in this section in addition to specifying the corresponding parameter in the tnsnames.ora file. See "Using tnsnames.ora files" for details.
1. Specify the primary and alternate servers:
a. Specify your primary server using a connection URL or data source.
b. Specify one or multiple alternate servers by setting the AlternateServers property.
See "Specifying primary and alternate servers".
Note: To turn off failover, do not specify a value for the AlternateServers property.
Note: If using failover with an Oracle RAC, the primary server must be a primary node and any alternate server must be a secondary node.
2. Choose a failover method by setting the FailoverMode connection property. The default method is connection failover (FailoverMode=connect). See "Using failover" for an overview of each failover method.
3. If FailoverMode=extended or FailoverMode=select, set the FailoverGranularity property to specify how you want the driver to behave if exceptions occur while trying to reestablish a lost connection. The default behavior of the driver is to continue with the failover process and post any exceptions on the statement on which they occur (FailoverGranularity=nonAtomic).
4. Optionally, configure the connection retry feature. See "Specifying connection retry".
5. Optionally, set the FailoverPreconnect property if you want the driver to establish a connection with the primary and an alternate server at the same time. The default behavior is to connect to an alternate server only when failover is caused by an unsuccessful connection attempt or a lost connection (FailoverPreconnect=false).