skip to main content
Using the ADO.NET Client : Using Connection Failover
 

Using Connection Failover

Connection failover allows an application to connect to an alternate, or backup, database server if the primary database is unavailable, for example, because of a hardware failure or traffic overload.
Refer to the OpenAccess SDK Administrator’s Guide for more information about connection failover.
To configure connection failover to another server, you must specify a list of alternate database servers that are tried at connection time if the primary server is not accepting connections. To do this, use the Alternate Servers connection string option. Connection attempts continue until a connection is successfully established or until all the databases in the list have been tried once (the default).
Optionally, you can specify the following additional connection failover features:
The number of times the data provider attempts to connect after the initial connection attempt. By default, the ADO.NET Client does not retry. To set this feature, use the Connection Retry Count connection string option.
The wait interval, in seconds, used between attempts to connect. The default interval is 3 seconds. To set this feature, use the Connection Retry Delay connection string option.
Whether the ADO.NET Client will use load balancing in its attempts to connect to primary and alternate servers. If load balancing is enabled, the ADO.NET Client uses a random pattern instead of a sequential pattern in its attempts to connect. The default value is not to use load balancing. To set this feature, use the Load Balancing connection string option.
You use a connection string to direct the ADO.NET Client to use connection failover. See Specifying Connection Options for information about using connection strings.
The following C# code fragment includes a connection string that configures the ADO.NET Client to use connection failover in conjunction with all of its optional features—load balancing, connection retry, and connection retry delay:
OpenAccessConnection Conn = new OpenAccessConnection();
Conn = new OpenAccessConnection("Host=server1;Port=19996;ServerDataSource=SDSN1:User ID=test;Password=secret;Alternate Servers=(Host=server2:Port=19996:ServerDataSource=SDSN2,Host=server3:Port=19996:ServerDataSource=SDSN3);Connection Retry Count=4;Connection Retry Delay=5;Load Balancing=true;
Connection Timeout=60"
Specifically, this connection string configures the ADO.NET Client to use two alternate servers as connection failover servers, to attempt to connect four additional times if the initial attempt fails, to wait five seconds between attempts, and to try the primary and alternate servers in a random order. Each connection attempt lasts for 60 seconds.