You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Meikel Bisping <M....@gmx.de> on 2005/04/12 10:34:14 UTC

[dbcp] invalidation failure?!

Hi,

I just realized that invalidation can fail if connection.close is
called afterwards.

e.g.

 String pooldrv="jdbc:apache:commons:dbcp:mypool";
PoolingDriver driver = (PoolingDriver) DriverManager
                .getDriver(pooldrv);

 Connection con=DriverManager.getConnection(pooldrv);
try{
   //something goes wrong with con
 //in my case an sql script creates some temporary tables and
//something might go wrong in the middle of the scipt.
//The validation mechanism can't test if there are temp. tables 
//left over, so principally the connection still works, but it's
//ruined for my sql scripts because some temp tables already exist
//Informix doesn't support create or replace temp table
 }
catch 
{
driver.getConnectionPool(poolname).invalidateObject(con);
}
con.close();

The particular connection is put pack into the pool and reused,
inspite of the fact that it has been invalidated before.
I realized that I could solve my problem by moving the con.close()
into the try-block, but shouldn't closing invalidated connections
still keep them invalidated?

Regards,

Meikel Bisping
                
            
      


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org