Configuring client affinities for applications that use DB2 databases

The client affinities feature is an alternative to automatic client reroute when enabling your data source to use other servers when a connection fails. In this client-only method, the client determines the order that alternate servers run during failover. For more information about client affinities, see the topic, Client affinities for DB2® Database for Linux®, UNIX, and Windows, in the DB2 documentation.

Before you begin

This task assumes that:
  • You have a DB2 data source defined in the application server. See the topic, Configuring a data source using the administrative console, for information about creating a data source.
  • The DB2 data source to which your application connects is running one of the following databases:
    • DB2 for z/OS® Version 9.1 or later
    • DB2 Database for Linux, UNIX, and Windows Version 9.5 or later
  • You have implemented the DB2 database with a redundant setup or the ability to fail the DB2 server to a standby node.

About this task

In WebSphere® Application Server, client affinities allows the DB2 data source on the client or application server to control the order of servers that are tried during initial connection processing.

For WebSphere Application Server, the data source custom property, enableClientAffinitiesList, is used to enable client affinities. If you want to use the administrative console to configure client affinities, use the DB2 automatic client reroute options section of the WebSphere Application Server data source properties panel to configure the following properties: Alternate server names, Alternate port numbers, Retry interval for client reroute, and Maximum retries for client reroute. You can also use the Custom properties panel to configure other client affinities properties as needed, including enableSeamlessFailover and affinityFailbackInterval.

The data source custom property, enableClientAffinitiesList, changes the semantics of the clientRerouteAlternateServerName and clientRerouteAlternatePortNumber properties.

Attention:
To learn more about these properties, see the DB2 documentation topic, Configuration of client affinities for Java™ clients for DB2 Database for Linux, UNIX, and Windows connections.

To configure client affinities in the application server, complete the following steps:

Procedure

  1. Configure a JDBC provider as usual with the JCC driver for DB2 in the class path.
  2. Create a data source that uses the JDBC provider that was created in step 1. The server name and port information must be the name of the preferred primary server from your DB2 WLB environment.
  3. After the data source is created, navigate to its primary panel in the administrative console by clicking Resources > JDBC > Data sources > data_source.
  4. Click WebSphere Application Server data source properties located under Additional Properties.
  5. Scroll down to the section DB2 automatic client reroute options.
  6. In the DB2 automatic client reroute options section, configure the Alternate server names, Alternate port numbers, Retry interval for client reroute, and Maximum retries for client reroute.
  7. Click OK, and save the changes.
  8. Navigate back to the data source primary panel, and click Custom properties located under Additional Properties.
  9. On the Custom properties panel, configure other client affinities properties as needed, including enableClientAffinitiesList, enableSeamlessFailover and affinityFailbackInterval.
    Read about the configuration of client affinities for Java clients for DB2 Database for Linux, UNIX, and Windows connections, in the DB2 documentation, for the recommended values for these properties.
  10. Click OK and save the changes.
  11. Restart the application server.