prestodb/presto · error · SQLException

ResultSet is closed

Error message

ResultSet is closed

What it means

checkOpen is a sentinel guard used at the start of nearly every PrestoResultSet method: if isClosed() returns true (after close() or statement/connection closure) it throws this SQLException, preventing access to a result set whose backing query resources have been released.

Source

Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java:1659

    }

    @Override
    public boolean isWrapperFor(Class<?> iface)
            throws SQLException
    {
        return iface.isInstance(this);
    }

    void partialCancel()
    {
        client.cancelLeafStage();
    }

    private void checkOpen()
            throws SQLException
    {
        if (isClosed()) {
            throw new SQLException("ResultSet is closed");
        }
    }

    private void checkValidRow()
            throws SQLException
    {
        if (row.get() == null) {
            throw new SQLException("Not on a valid row");
        }
    }

    private Object column(int index)
            throws SQLException
    {
        checkOpen();
        checkValidRow();
        if ((index <= 0) || (index > resultSetMetaData.getColumnCount())) {
            throw new SQLException("Invalid column index: " + index);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify the result set is not closed before calling getters, or keep a reference until done reading rows
  2. Check whether the owning Statement/Connection was closed prematurely (try-with-resources ordering)
  3. Guard generic JDBC framework code with isClosed() checks or catch the SQLException
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java:1659 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/fa20c1677316621d. Report an issue: GitHub.