/** * Closes connection and detaches it from current thread. * @param suppressWarning true to not display a warning in case of a problem (connection not there) */ public void close(boolean suppressWarning) { try { Connection connection = ConnectionsAccess.getConnection(name); if(connection == null){ throw new DBException("cannot close connection '" + name + "' because it is not available"); } StatementCache.instance().cleanStatementCache(connection); connection.close(); LogFilter.log(LOGGER, LogLevel.DEBUG, "Closed connection: {}", connection); } catch (Exception e) { if (!suppressWarning) { LOGGER.warn("Could not close connection! MUST INVESTIGATE POTENTIAL CONNECTION LEAK!", e); } } finally { ConnectionsAccess.detach(name); // let's free the thread from connection } }
/** * Detaches a connection from current thread and returns an instance of it. This method does not close a connection. * Use it for cases of advanced connection management, such as integration with Spring Framework. * * @return instance of a connection detached from current thread by name passed to constructor. */ public Connection detach() { Connection connection = ConnectionsAccess.getConnection(name); try { if (connection == null) { throw new DBException("cannot detach connection '" + name + "' because it is not available"); } ConnectionsAccess.detach(name); // let's free the thread from connection StatementCache.instance().cleanStatementCache(connection); } catch (DBException e) { LogFilter.log(LOGGER, LogLevel.ERROR, "Could not close connection! MUST INVESTIGATE POTENTIAL CONNECTION LEAK!", e); } return connection; }
/** * Detaches a connection from current thread and returns an instance of it. This method does not close a connection. * Use it for cases of advanced connection management, such as integration with Spring Framework. * * @return instance of a connection detached from current thread by name passed to constructor. */ public Connection detach() { Connection connection = ConnectionsAccess.getConnection(name); try { if (connection == null) { throw new DBException("cannot detach connection '" + name + "' because it is not available"); } ConnectionsAccess.detach(name); // let's free the thread from connection StatementCache.instance().cleanStatementCache(connection); } catch (DBException e) { logger.warn("Could not close connection! MUST INVESTIGATE POTENTIAL CONNECTION LEAK!", e); } return connection; }
/** * Closes connection and detaches it from current thread. * @param suppressWarning true to not display a warning in case of a problem (connection not there) */ public void close(boolean suppressWarning) { try { Connection connection = ConnectionsAccess.getConnection(name); if(connection == null){ throw new DBException("cannot close connection '" + name + "' because it is not available"); } StatementCache.instance().cleanStatementCache(connection); connection.close(); LogFilter.log(logger, "Closed connection: {}", connection); } catch (Exception e) { if (!suppressWarning) { logger.warn("Could not close connection! MUST INVESTIGATE POTENTIAL CONNECTION LEAK!", e); } } finally { ConnectionsAccess.detach(name); // let's free the thread from connection } }
/** * Closes connection and detaches it from current thread. * @param suppressWarning true to not display a warning in case of a problem (connection not there) */ public void close(boolean suppressWarning) { try { Connection connection = ConnectionsAccess.getConnection(name); if(connection == null){ throw new DBException("cannot close connection '" + name + "' because it is not available"); } StatementCache.instance().cleanStatementCache(connection); connection.close(); LogFilter.log(LOGGER, LogLevel.DEBUG, "Closed connection: {}", connection); } catch (Exception e) { if (!suppressWarning) { LOGGER.warn("Could not close connection! MUST INVESTIGATE POTENTIAL CONNECTION LEAK!", e); } } finally { ConnectionsAccess.detach(name); // let's free the thread from connection } }
/** * Detaches a connection from current thread and returns an instance of it. This method does not close a connection. * Use it for cases of advanced connection management, such as integration with Spring Framework. * * @return instance of a connection detached from current thread by name passed to constructor. */ public Connection detach() { Connection connection = ConnectionsAccess.getConnection(name); try { if (connection == null) { throw new DBException("cannot detach connection '" + name + "' because it is not available"); } ConnectionsAccess.detach(name); // let's free the thread from connection StatementCache.instance().cleanStatementCache(connection); } catch (DBException e) { LogFilter.log(LOGGER, LogLevel.ERROR, "Could not close connection! MUST INVESTIGATE POTENTIAL CONNECTION LEAK!", e); } return connection; }