Skip to content

Instantly share code, notes, and snippets.

@ipolevoy
Created December 16, 2012 20:50
Show Gist options
  • Save ipolevoy/4312786 to your computer and use it in GitHub Desktop.
Save ipolevoy/4312786 to your computer and use it in GitHub Desktop.
public void close() {
try {
Connection connection = ConnectionsAccess.getConnection(dbName);
if(connection == null){
throw new DBException("cannot close connection '" + dbName + "' because it is not available");
}
StatementCache.instance().cleanStatementCache(connection);
connection.close();
LogFilter.log(logger, "Closed connection: " + connection);
} catch (Exception e) {
logger.warn("Could not close connection! MUST INVESTIGATE POTENTIAL CONNECTION LEAK!", e);
}finally{
ConnectionsAccess.detach(dbName);// lets free the thread from connection
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment