I have a Class which performs
JDBC calls on a DB2 Database
The Database connections are pooled via the datasource,
There is a method called getdbconnection() which obtains a pooled connection.
The issue is that the method to obtain a connection and the method to release a connection are synchronized methods on the same object (DBConnectionPool). Therefore, at any given time, only one of those methods can be called.
When the data source connection pool runs out of connections calls to DBConnectionPool.getPooledConnection() block waiting for a connection to be returned. Calls to DBConnectionPool.releasePooledConnections() then have to wait for the calls to DBConnectionPool.getPooledConnection to unblock.
Because the calls to return a connection are waiting for the calls to get a connection no connections will ever be returned and therefore no connections will ever be given causing the dead lock.
Your assistance is appreciated.
Here is example of the code: