The state when the connections are pooled up to the maximum number specified for the connection pool and there are no usable connections in the pool is called connection depletion.
When the connections deplete, you can set the connection requests to a pending state. The pending connection requests can obtain a connection as soon as a connection is released. Due to this, connections can be obtained efficiently when the connections are depleted. The following figure shows the process of waiting to obtain a connection when connections deplete.
Figure 3-36 Waiting for a connection when connections deplete
In this figure, the maximum number of the connection pool is 2. Therefore, even if there are connection requests from four getConnection methods, only up to two requests can be processed. The first two connection requests can obtain the connections because there are connections in the connection pool. The remaining two are in the connection depletion state, so these requests enter the connection pending queue and wait for a connection to be released.
Note that you can specify settings to wait to obtain a connection when you use a connection pool.
To wait to obtain a connection, you must set up the following content as the resource adapter properties:
For details on the resource adapter settings, see 3.15.13 Settings in the execution environment.
When you specify settings to wait to obtain a connection, the connection requests during connection depletion enter a pending state. If the waiting time for obtaining a connection request exceeds the maximum waiting time, an exception will be thrown in the user program.
Also, the connection requests are restarted at one of the following times:
Note that if an error occurs after the connection requests are restarted, the retry processing is executed if the connection retry functionality is enabled.