How to test a datasource connection before assigning to application ?

When we create a datasource in websphere and it is assigned to application . During the odd situation where network glitch or what ever so reason if there is a problem and the connection assigned to the application goes stale then will get the below error .

com.ibm.websphere.ce.cm.StaleConnectionException: Io exception: Broken pipe

How to enable database connection testing in WebSphere

To have WebSphere automatically check the validity of a connection when serving it up from the connection pool do the following:

  1. In the administrative console, click Resources > JDBC providers.
  2. Select a provider and click Data Sources under Additional properties.
  3. Select a data source and click WebSphere Application Server data source properties under Additional properties.
  4. Select the PreTest Connections check box.
  5. Type a value for the PreTest Connection Retry Interval, which is measured in seconds. This property determines the frequency with which a new connection request is made after a pretest operation fails.
  6. Type a valid SQL statement for the PreTest SQL String. Use a reliable SQL command, with minimal performance impact; this statement is processed each time a connection is obtained from the free pool.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *