@Override public final void close() throws SQLException { closed = true; HintManagerHolder.clear(); MasterVisitedManager.clear(); TransactionTypeHolder.clear(); int connectionSize = cachedConnections.size(); try { forceExecuteTemplateForClose.execute(cachedConnections.entries(), new ForceExecuteCallback<Entry<String, Connection>>() { @Override public void execute(final Entry<String, Connection> cachedConnections) throws SQLException { cachedConnections.getValue().close(); } }); } finally { cachedConnections.clear(); rootInvokeHook.finish(connectionSize); } }
/** * Close cached connection. * * @param forceClose force close flag * @throws SQLException SQL exception */ public synchronized void close(final boolean forceClose) throws SQLException { Collection<SQLException> exceptions = new LinkedList<>(); MasterVisitedManager.clear(); exceptions.addAll(closeStatements()); exceptions.addAll(closeResultSets()); if (!stateHandler.isInTransaction() || forceClose) { exceptions.addAll(releaseConnections(forceClose)); } stateHandler.doNotifyIfNecessary(); throwSQLExceptionIfNecessary(exceptions); }
/** * Close cached connection. * * @param forceClose force close flag * @throws SQLException SQL exception */ public synchronized void close(final boolean forceClose) throws SQLException { Collection<SQLException> exceptions = new LinkedList<>(); MasterVisitedManager.clear(); exceptions.addAll(closeStatements()); exceptions.addAll(closeResultSets()); if (!stateHandler.isInTransaction() || forceClose) { exceptions.addAll(releaseConnections(forceClose)); } stateHandler.doNotifyIfNecessary(); throwSQLExceptionIfNecessary(exceptions); }