You must enable the seamless failover feature with WebSphere® Application Server Liberty profile and WebSphere Application Server. With this feature, you can manage an exception when a database fails over and gets rerouted by the DB2® JDBC driver.
By default with DB2 HADR, when the DB2 JDBC driver performs a client reroute after detecting that a database failed over during the first attempt to reuse an existing connection, the driver triggers com.ibm.db2.jcc.am.ClientRerouteException, with ERRORCODE=-4498 and SQLSTATE=08506. WebSphere Application Server maps this exception to com.ibm.websphere.ce.cm.StaleConnectionException before it is received by the application.
In this case, the application would have to catch the exception and execute again the transaction. The MobileFirst and Application Center runtime environments do not manage the exception but rely on a feature that is called seamless failover. To enable this feature, you must set the enableSeamlessFailover JDBC property to "1".
<dataSource jndiName="jdbc/WorklightAdminDS" transactional="false">
<jdbcDriver libraryRef="DB2Lib"/>
<properties.db2.jcc databaseName="WLADMIN" currentSchema="WLADMSC"
serverName="db2server" portNumber="50000"
enableSeamlessFailover= "1"
user="worklight" password="worklight"/>
</dataSource>
enableSeamlessFailover : 1
For more information about how to configure a connection to an HADR-enabled DB2 database, see Setting up a connection to an HADR-enabled DB2 database.