For connections to DB2® for Linux, UNIX, and Windows databases,
the process for configuration of automatic client reroute support
on Java™ clients is the same
for connections to a non-DB2 pureScale® environment and
a DB2 pureScale environment.
Automatic client reroute support for Java client
applications that connect to DB2 for Linux, UNIX, and Windows works
for connections that are obtained using the javax.sql.DataSource, javax.sql.ConnectionPoolDataSource, javax.sql.XADataSource,
or java.sql.DriverManager interface.
To configure automatic client reroute on a IBM® Data Server Driver for JDBC and SQLJ client:
- Set the appropriate properties to specify the primary and alternate
server addresses to use if the first connection fails.
- If your application is using the DriverManager interface
for connections:
- Specify the server name and port number of the primary server
that you want to use in the connection URL.
- Set the clientRerouteAlternateServerName and clientRerouteAlternatePortNumber
properties to the server name and port number of the alternate server
that you want to use.
Restriction: Automatic client reroute support for
connections that are made with the
DriverManager interface
has the following restrictions:
- Alternate server information is shared between DriverManager connections
only if you create the connections with the same URL and properties.
- You cannot set the clientRerouteServerListJNDIName property or
the clientRerouteServerListJNDIContext properties for a DriverManager connection.
- Automatic client reroute is not enabled for default connections
(jdbc:default:connection).
- If your application is using the DataSource interface
for connections, use one or both of the following techniques:
- Set the server names and port numbers in DataSource properties:
- Set the serverName and portNumber properties to the server name
and port number of the primary server that you want to use.
- Set the clientRerouteAlternateServerName and clientRerouteAlternatePortNumber
properties to the server name and port number of the alternate server
that you want to use.
- Configure JNDI for automatic client reroute by using a DB2ClientRerouteServerList instance
to identify the primary server and alternate server.
- Create an instance of DB2ClientRerouteServerList.
DB2ClientRerouteServerList is
a serializable Java bean with
the following properties:
Property name |
Data type |
com.ibm.db2.jcc.DB2ClientRerouteServerList.alternateServerName |
String[] |
com.ibm.db2.jcc.DB2ClientRerouteServerList.alternatePortNumber |
int[] |
com.ibm.db2.jcc.DB2ClientRerouteServerList.primaryServerName |
String[] |
com.ibm.db2.jcc.DB2ClientRerouteServerList.primaryPortNumber |
int[] |
getXXX and setXXX methods
are defined for each property.
- Set the com.ibm.db2.jcc.DB2ClientRerouteServerList.primaryServerName and com.ibm.db2.jcc.DB2ClientRerouteServerList.primaryPortNumber properties
to the server name and port number of the primary server that you
want to use.
- Set the com.ibm.db2.jcc.DB2ClientRerouteServerList.alternateServerName and com.ibm.db2.jcc.DB2ClientRerouteServerList.alternatePortNumber properties
to the server names and port numbers of the alternate server that
you want to use.
- To make the DB2ClientRerouteServerList persistent:
- Bind the DB2ClientRerouteServerList instance
to the JNDI registry.
- Assign the JNDI name of the DB2ClientRerouteServerList object
to the IBM Data Server Driver for JDBC and SQLJ clientRerouteServerListJNDIName
property.
- Assign the name of the JNDI context that is used for binding and
lookup of the DB2ClientRerouteServerList instance to the clientRerouteServerListJNDIContext
property.
When a DataSource is configured to use
JNDI for storing automatic client reroute alternate information, the
standard server and port properties of the DataSource are
not used for a getConnection request. Instead,
the primary server address is obtained from the transient clientRerouteServerList information.
If the JNDI store is not available due to a JNDI bind or lookup failure,
the IBM Data Server Driver for JDBC and SQLJ
attempts to make a connection using the standard server and port properties
of the DataSource. Warnings are accumulated to
indicate that a JNDI bind or lookup failure occurred.
After
a failover:
- The IBM Data Server Driver for JDBC and SQLJ attempts
to propagate the updated server information to the JNDI store.
- primaryServerName and primaryPortNumber values that are specified
in DB2ClientRerouteServerList are used for the connection. If primaryServerName
is not specified, the serverName and portNumber values for the DataSource instance
are used.
If you configure DataSource properties
as well as configuring JNDI for automatic client reroute, the DataSource properties
have precedence over the JNDI configuration.
- Set properties to control the number of retries, time between
retries, and the frequency with which the server list is refreshed.
The
following properties control retry behavior for automatic client reroute.
- maxRetriesForClientReroute
- The maximum number of connection retries for automatic client
reroute.
When client affinities support is not configured, if maxRetriesForClientReroute
or retryIntervalForClientReroute is not set, the default behavior
is that the connection is retried for 10 minutes, with a wait time
between retries that increases as the length of time from the first
retry increases.
When client affinities is configured, the default
for maxRetriesForClientReroute is 3.
- retryIntervalForClientReroute
- The number of seconds between consecutive connection retries.
When
client affinities support is not configured, if retryIntervalForClientReroute
or maxRetriesForClientReroute is not set, the default behavior is
that the connection is retried for 10 minutes, with a wait time between
retries that increases as the length of time from the first retry
increases.
When client affinities is configured, the default
for retryIntervalForClientReroute is 0 (no wait).