There seems to be couple of possibilities
1) Long running genuine SQL's
2) Untuned SQL's which are taking longer time to get execute thus making the connection unavailable to pool for longer time .
For the "long running SQL's " you would have to configure the pool with larger number of connections and for the latter case you got to optimize the application code (fine tune SQL's) .
Very helpful, thank you. Took a look at the root of some of these, X-referenced with with "Slow Query Log" on our DB, and found this to very possibly be the root of the problem.
During performance tests on JBoss 4.2.3.GA we've also faced much BLOCKED threads on
The connection pool was not exhausted.
Digging in sources led to this:
286 if (debug)
288 synchronized (connectionStackTraces)
290 connectionStackTraces.put(connection, new Throwable("STACKTRACE"));
So the problem is not about slow sql but about debug synchronization.
This can be disabled in deploy/jbossjca-service.xml with <attribute name="Debug">false</attribute>.
It gave us 25% performance improvement!