public void close()

in src/main/java/org/apache/commons/dbcp2/DelegatingStatement.java [132:172]


    public void close() throws SQLException {
        if (isClosed()) {
            return;
        }
        final List<Exception> thrownList = new ArrayList<>();
        try {
            if (connection != null) {
                connection.removeTrace(this);
                connection = null;
            }

            // The JDBC spec requires that a statement close any open
            // ResultSet's when it is closed.
            // FIXME The PreparedStatement we're wrapping should handle this for us.
            // See bug 17301 for what could happen when ResultSets are closed twice.
            final List<AbandonedTrace> traceList = getTrace();
            if (traceList != null) {
                traceList.forEach(trace -> trace.close(e -> {
                    if (connection != null) {
                        // Does not rethrow e.
                        connection.handleExceptionNoThrow(e);
                    }
                    thrownList.add(e);
                }));
                clearTrace();
            }
            Utils.close(statement, e -> {
                if (connection != null) {
                    // Does not rethrow e.
                    connection.handleExceptionNoThrow(e);
                }
                thrownList.add(e);
            });
        } finally {
            closed = true;
            statement = null;
            if (!thrownList.isEmpty()) {
                throw new SQLExceptionList(thrownList);
            }
        }
    }