So I discovered an issue when attempting to implement BoneCP in our database class. The way we have our class architected we have a method called getPreparedStatement that gets a conenction from the pool and returns the preparedstatment, we then call another method executePreparedStatement which returns a resultset. After the resultset is used we call a method called releaseResources which accepts a results set and gets the connection from the resultset using statment and then attempts to close it (see Below). The issue is that the connection thats returned from the resultset isn't the actual connection but a shadow object of the original connection. So therefore the connections are never released from the pool. DBCP had this same issue and I believe proxool still has it. I REALLY REALLY REALLY do not want to use DBCP!!!! Has anyone encountered this before and can anyone provide anyway to resolve this short of rearchitecting this class or using a result caching method as at least for this release this will not be an option. Don't hate on the architecture its not mine i'm just charged with fixing it!
------------------------ Example ------------------------
public void releaseResources(ResultSet rs)
{
Statement stmt = null;
Connection conn = null;
try
{
stmt = rs.getStatement();
conn = stmt.getConnection();
}
catch(SQLException e)
{
RALogger.logMessage("Error releasing resources.","ERROR");
e.printStackTrace();
}
finally
{
if(rs != null) rs.close();
if(stmt != null) stmt.close();
if(conn != null && !conn.isClosed()) conn.close();
}
}
--------------------------- End ---------------------------
DBCP bug report and fix.
https://issues.apache.org/jira/browse/DBCP-11
Thanks
Brian Swingle
