Under server load if the transactions are holding database connections for a long time then one might face the problem with Hibernate’s GenericJDBCException: Cannot open connection. Though it indicates that it has reached maximum pool size and cannot open further connections the question is how do we reproduce the problem!
The easy way I found was to use the classic JMeter. Reducing the max-pool-size further to a low number made it even easier to reproduce the problem.
Clear instructions on using the JMeter for mocking requests to server can be found here:
http://jmeter.apache.org/usermanual/build-web-test-plan.html
A little more advance guide is http://jmeter.apache.org/usermanual/build-adv-web-test-plan.html
In this way we could make all the db-connections busy and it could not further open a new connection because of max-pool-size. The challenge for us is to optimize the code still maintaining a single transaction so that a manual rollback could be triggered.
