Close connection and sql statement in a clean way.

@param connection    Connection to close.
@param stmt          Statement to close.
174827
private void cleanConnectionClose(Connection connection, Statement stmt) {
        try {
            // clean close
            if (connection != null) {
                connection.rollback();
            }

            if (stmt != null) {
                stmt.close();
            }

            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e1) {
            e1.printStackTrace();
        }
    }
1088902
public void close(ResultSet rs, Statement st, Connection conn) {
		if (rs != null) {try {rs.close();} catch (SQLException e) {LogKit.error(e.getMessage(), e);}}
		if (st != null) {try {st.close();} catch (SQLException e) {LogKit.error(e.getMessage(), e);}}
		
		if (threadLocal.get() == null) {	// in transaction if conn in threadlocal
			if (conn != null) {try {conn.close();}
			catch (SQLException e) {throw new ActiveRecordException(e);}}
		}
	}
1030697
public static void closeConnection(Connection connection)
        throws InternalErrorException {

        if (connection != null) {
            try {
                connection.close();
            } catch (SQLException e) {
                throw new InternalErrorException(e);
            }
        }

    }
611817
protected void destroyConnection(ThriftConnectionHandle<T> conn) {
		postDestroyConnection(conn);
		try {
			conn.internalClose();
		} catch (ThriftConnectionPoolException e) {
			logger.error("Error in attempting to close connection", e);
		}
	}
1269867
public static void closeQuietly(Connection conn, Statement stmt,
            ResultSet rs) {

        try {
            closeQuietly(rs);
        } finally {
            try {
                closeQuietly(stmt);
            } finally {
                closeQuietly(conn);
            }
        }

    }
262065
protected void closeConnection(ConnectionHandle connection) {
		if (connection != null) {
			try {
				connection.internalClose();
			} catch (Throwable t) {
				logger.error("Destroy connection exception", t);
			} finally {
				this.pool.postDestroyConnection(connection);
			}
		}
}
1171721
private void executeImmediate(String stmtText) throws SQLException
  {
    // execute the statement and auto-close it as well
    try (final Statement statement = this.createStatement())
    {
      statement.execute(stmtText);
    }
  }
794700
void connectionClosed(final SibRaConnection connection) {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "connectionClosed", connection);
        }

        final ConnectionEvent event = new ConnectionEvent(this,
                ConnectionEvent.CONNECTION_CLOSED);
        event.setConnectionHandle(connection);

        for (Iterator iterator = _eventListeners.iterator(); iterator.hasNext();) {

            final ConnectionEventListener listener = (ConnectionEventListener) iterator
                    .next();
            listener.connectionClosed(event);

        }

        _connections.remove(connection);

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, "connectionClosed");
        }

    }
1345059
public function close(?string $connection = null): void
	{
		$connection = $connection ?? $this->default;

		if(isset($this->connections[$connection]))
		{
			if(method_exists($this->connections[$connection], 'close'))
			{
				// Call close on the connection object in case there's a reference
				// to the connection that won't be garbage collected immediately

				$this->connections[$connection]->close();
			}

			unset($this->connections[$connection]);
		}
	}
274278
protected void removeConnection(ConnectionImpl connection) {
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.entry(tc, "removeConnection", connection);

        synchronized (_connections) {
            _connections.remove(connection);
        }

        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.exit(tc, "removeConnection");
    }
1144260
public void releaseConnection(ThriftConnection<T> connection) throws ThriftConnectionPoolException {
		ThriftConnectionHandle<T> handle = (ThriftConnectionHandle<T>) connection;

		// 判断连接池是否是在关闭中 如果不是在关闭中则执行回收操作
		if (!this.poolShuttingDown) {
			internalReleaseConnection(handle);
		}
	}
1358982
public void close() throws SQLException
	{
		more = false;
		if(!exclusive)
			return;
		if(rs != null)
		{
			rs.close();
			rs = null;
		}
		if(stmt != null)
		{
			stmt.close();
			stmt = null;
		}
	}
1117152
public static void close(@Nullable Connection con) throws SQLException {
		if (con != null && !con.isClosed()) {
			if (!con.getAutoCommit()) {
				con.rollback();
				con.setAutoCommit(true);
			}
			con.close();
		}
	}
590279
protected void closeResources(Connection connection) {
        if (cacheConnection) return;
        if (connection != null && dataSource != null) {
            try {
                connection.close();
            } catch (SQLException e) {
                LOG.finest("Caught exception closing connection: " + e.getMessage() + " - continuing");
            }
        }
    }
578306
public synchronized void close() {
        acceptor.quit();
        OtpCookedConnection conn;
        final Collection<OtpCookedConnection> coll = connections.values();
        final Iterator<OtpCookedConnection> it = coll.iterator();

        mboxes.clear();

        while (it.hasNext()) {
            conn = it.next();
            it.remove();
            conn.close();
        }
        initDone = false;
    }
274153
public void close() {
        try {
            state = "CLOSING";
            if( connection != null ) {
                logger.warn("Connection not committed, rolling back.");
                rollback();
            }
            if( !events.empty() ) {
                state = "CLOSING EVENTS";
                do {
                    Execution exec = (Execution)events.pop();
                
                    try {
                        Stack<Execution> stack;
                        
                        exec.close();
                        stack = eventCache.get(exec.getClass().getName());
                        if( stack != null ) {
                            stack.push(exec);
                        }
                    }
                    catch( Throwable t ) {
                        logger.error(t.getMessage(), t);
                    }
                } while( !events.empty() );
            }
            state = "CLOSED";
        }
        finally {
            if (tracking) {
                transactions.remove(new Integer(transactionId));
            }
            events.clear();
            statements.clear();
            stackTrace = null;
        }
    }
360919
public static void closeConnection( Connection conn, Logger logger ) {

		try {
			if( conn != null )
				conn.close();

		} catch( SQLException e ) {
			// Not important.
			Utils.logException( logger, e );
		}
	}