Bootstrap FreeKB - IBM WebSphere - JDBC ConnectionWaitTimeout
IBM WebSphere - JDBC ConnectionWaitTimeout

Updated:   |  IBM WebSphere articles

Simply put, a ConnectionWaitTimeout exception will occur when the connection timeout period has been exceeded. In this example, the connection timeout period is 180 seconds. When a connection has been waiting longer than 180 seconds, a ConnectionWaitTimeout exception will occur.


In the WebSphere admin console, you will navigate to Resources > JDBC > Data sources > your data source > Connection pool properties to view and update the connection timeout.


Example scenario

10 different user connect to the database and a poorly written SQL statement causes the connections to remain active for a long time. Another user attempt to connect to the database. Since the maximum connections is 10, the new user must wait. If the new user is waiting for 180 second, the ConnectionWaitTimeout exception will occur.


Don't abuse Maximum connections

You may ask yourself, why would we ever want to limit the maximum connections? In an enterprise setting, you may find yourself in a situation where you have hundreds or possibly even thousands of different data sources, each with their own connection pool. If you were not to limit the maximum connections in each connection pool, the database could become overloaded with requests. This is why each connection pool limits the number of simultaneous connections that can be made to the database.

If you have multiple data sources connecting to the same backend database, you will need to be careful not to overload the backend database. For example, if you have 10 data sources with a maximum connections of 50, this creates a maximum of 500 possible connects to the same backend database, which may overload the database, or reduce the performance of the database. It is generally a good idea to set the maximum allowed connections to be less than the maximum threads of a web container.

Next, you'll want to know if 10 connections to the database is an appropriate value. In the WebSphere admin console, navigate to Monitoring and Tuning > Performance viewer > Current activity > select an application server. At the viewer, select JDBC Connection Pools and then select View Modules. In this example, the red line indicates there are 2 connections to the database, thus a maximum of 10 should be perfectly OK.


Disable the timeout

Setting the connection timeout to 0 will disable the timeout, which means that each connection will continue indefinitely and will never produce a ConnectionWaitTimeout exception will occur. This is almost always a bad idea.


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter c1cd8e in the box below so that we can be sure you are a human.