commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Re: [dbcp] Error when closing a connection (maybe DBCP-216?)
Date Tue, 13 Nov 2007 09:44:14 GMT
hi again,

thanks for the answer. I looked at the random connection closed exceptions 
but I'm correctly closing my connections. I've attached a stacktrace that 
happen later, sorry, it was of course less obvious to figure out like 
that... Here is the first exception I have:

Thread [pool-5-thread-4] (Suspended (exception IllegalStateException)) 
        KeyedCPDSConnectionFactory.connectionClosed(ConnectionEvent) line: 
        SybPooledConnection.notifyListeners(SQLException) line: 225 
        SybConnectionProxy.close() line: 106 
        SybPooledConnection.close() line: 166 
        KeyedCPDSConnectionFactory.destroyObject(Object, Object) line: 175 

        GenericKeyedObjectPool.returnObject(Object, Object) line: 997 
        KeyedCPDSConnectionFactory.connectionClosed(ConnectionEvent) line: 
        SybPooledConnection.notifyListeners(SQLException) line: 225 
        SybConnectionProxy.close() line: 106 
        ... (i'm calling close on the SQL Connection here, when the thread 
is finished)

After analyzing it a bit I understand the pool wants to destroy the object 
because my pool can not support any more idle connection (I'm at the point 
where active=maxActive=maxIdle=5).
What I do not understand is why the destroyObject method does:

public void destroyObject(Object key, Object obj) throws Exception {
        if (obj instanceof PooledConnectionAndInfo) {
            PooledConnection pc = 

Which means it removes the mapping and close the PooledConnection. At this 
point, the listener is still active and it calls the listener which will 
obviously fail:

public void connectionClosed(ConnectionEvent event) {
        PooledConnection pc = (PooledConnection)event.getSource();
        // if this event occured becase we were validating, ignore it
        // otherwise return the connection to the pool.
        if (!validatingMap.containsKey(pc)) {
            PooledConnectionAndInfo info =
                (PooledConnectionAndInfo) pcMap.get(pc);
            if (info == null) {
                throw new IllegalStateException(NO_KEY_MESSAGE);   // 
<--------- the Exception which is thrown

Isn't this Or maybe the 
driver should not notify for both the Connection and PooledConnection 
Do you have any solution?

Thanks you for your patience :)

best regards,


gives a discussion of "Random Connection closed Exceptions" which may help 


Hi all !

I'm using a SharedDataPool and when I try to close the Connection to 
return it to the pool at some point, I get the following exception: 

Exception in thread "pool-7-thread-1" java.lang.IllegalStateException: 
close() was called on a Connection, but I have no record of the underlying 
PooledConnection. at 



I use dbcp-1.2.2 with sybase jConnect 6.05 and I don't understand the 
problem ... who is the culprit: the driver, dbcp or me? If I do not return 
this connection to the pool, I'm endin up quickly without any connection 
left :-/ 

Thanks for helping me.

Best regards,


This message and any attachments (the "message") is
intended solely for the addressees and is confidential. 
If you receive this message in error, please delete it and 
immediately notify the sender. Any use not in accord with 
its purpose, any dissemination or disclosure, either whole 
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message. 
BNP PARIBAS (and its subsidiaries) shall (will) not 
therefore be liable for the message if modified. 


Ce message et toutes les pieces jointes (ci-apres le 
"message") sont etablis a l'intention exclusive de ses 
destinataires et sont confidentiels. Si vous recevez ce 
message par erreur, merci de le detruire et d'en avertir 
immediatement l'expediteur. Toute utilisation de ce 
message non conforme a sa destination, toute diffusion 
ou toute publication, totale ou partielle, est interdite, sauf 
autorisation expresse. L'internet ne permettant pas 
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce 
message, dans l'hypothese ou il aurait ete modifie.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message