tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AndyG <>
Subject Re: DBCP Connection pool blocks threads on open/close connections
Date Tue, 15 Feb 2011 09:50:03 GMT

Found this post that is pretty close to what you are experiencing.

Their suggestion is to use a more recent version of DBCP, but this is not
really going to be an option as OpenEJB packages 1.3.

Starvation occurs when all your 30 checked out connections cannot be put
back - due to the above bug in DBCP.

What I would suggest is that you ensure that your DbHelper.closeConnection
and I presume DbHelper.getConnection are internally synchronized on the same
static final Object - Or if you don't have access to that code then wrap it
in your own synchronized factory.

public static Connection getConnection() throws Throwable {
    final Connection con;
        con = ...get the con...

    return con;

public static void closeConnection(final Connection con){    
        if(null != con){
            ...really make sure this con is closed, catch and log Throwable


grigory wrote:
> We do request multiple connections within single transaction.

Not to the same database I hope? A connection can create as many statements
as required for any unit of work. You should be passing about a single
connection to the same database within the transaction / thread scope - give
the connection back before you leave the scope and do not return from the
current thread scope until 'after' the finally.

Enter scope...
Get con...
Do work..(Do not return here)
    Close con...
Return from scope here...

You should drop the connection test unless you actually get stale connection
TestOnBorrow false

View this message in context:
Sent from the OpenEJB User mailing list archive at

View raw message