public List execute()

in src/main/java/org/apache/commons/dbutils/QueryRunner.java [258:298]


    public <T> List<T> execute(final Connection conn, final String sql, final ResultSetHandler<T> rsh, final Object... params) throws SQLException {
        if (conn == null) {
            throw new SQLException("Null connection");
        }

        if (sql == null) {
            throw new SQLException("Null SQL statement");
        }

        if (rsh == null) {
            throw new SQLException("Null ResultSetHandler");
        }

        CallableStatement stmt = null;
        final List<T> results = new LinkedList<>();

        try {
            stmt = prepareCall(conn, sql);
            this.fillStatement(stmt, params);
            boolean moreResultSets = stmt.execute();
            // Handle multiple result sets by passing them through the handler
            // retaining the final result
            while (moreResultSets) {
                try (@SuppressWarnings("resource")
                // assume the ResultSet wrapper properly closes
                ResultSet resultSet = wrap(stmt.getResultSet())) {
                    results.add(rsh.handle(resultSet));
                    moreResultSets = stmt.getMoreResults();
                }
            }
            retrieveOutParameters(stmt, params);

        } catch (final SQLException e) {
            rethrow(e, sql, params);

        } finally {
            close(stmt);
        }

        return results;
    }