Failover
- Last Updated: March 1, 2022
- 3 minute read
- DataDirect Connectors
- JDBC
- IBM Informix 6.0
- Documentation
The driver provides the following levels of failover protection to ensure continuous, uninterrupted access to data.
- Connection failover provides failover protection for new connections only. The driver fails over new connections to an alternate, or backup, database server if the primary database server is unavailable, for example, because of a hardware failure or traffic overload. If a connection to the database is lost, or dropped, the driver does not fail over the connection. This failover method is the default.
- Extended connection failover provides failover protection for new connections and lost database connections. If a connection to the database is lost, the driver fails over the connection to an alternate server, preserving the state of the connection at the time it was lost, but not any work in progress.
- Select Connection failover provides failover protection for new connections and lost database connections. In addition, it provides protection for Select statements that have work in progress. If a connection to the database is lost, the driver fails over the connection to an alternate server, preserving the state of the connection at the time it was lost and preserving the state of any work being performed by Select statements.
To configure failover:
- Specify the primary and alternate servers:
- Specify your primary server using a connection URL or data source.
- Specify one or multiple alternate servers by setting the AlternateServers
property.Note: To turn off failover, do not specify a value for the AlternateServers property.
- Choose a failover method by setting the FailoverMode connection property. The default
method is connection failover
(FailoverMode=connect). - If FailoverMode=
extendedor 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). - Optionally, configure the connection retry feature by setting the ConnectionRetryCount and ConnectionRetryDelay connection properties.
- 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).
The following examples configure the driver to use connection failover in conjunction with connection retry.
Connection URL
jdbc:datadirect:informix://myserver1:2003;InformixServer=myinformixserver1;
DatabaseName=payroll;User=jsmith;Password=secret;
AlternateServers=(myserver2:2003;InformixServer=myinformixserver2,myserver3:2003);
ConnectionRetryCount=2;ConnectionRetryDelay=5
In this example:
...myserver1:2003;InformixServer=myinformixserver1;DatabaseName=payroll...
is the part of the connection URL that specifies connection information for the primary server. Alternate servers are specified using the AlternateServers property. For example:
...;AlternateServers=(myserver2:2003;InformixServer=myinformixserver2,myserver3:
2003)
If a successful connection is not established on the Informix driver’s first pass through the
list of database servers (primary and alternate), the driver retries the list of servers in
the same sequence twice (ConnectionRetryCount=2). Because the
connection retry delay has been set to five seconds (ConnectionRetryDelay=5), the driver waits five seconds between retry passes.
InformixDataSource mds = new InformixDataSource();
mds.setDescription("My Informix Data Source");
mds.setServerName("myserver");
mds.setPortNumber("1526");
mds.setInformixServer("myinformixserver1");
mds.setDatabase("payroll");
mds.setUser("jsmith");
mds.setPassword("secret");
mds.setAlternateServers("myserver2:2003;InformixServer=myinformixserver2,
myserver3:2003");