tursodatabase/turso · error · java.sql.SQLException

ResultSet is not open

Error message

ResultSet is not open

What it means

get(int columnIndex) re-checks isOpen() before touching the last step result; this message ('ResultSet is not open') is a different wording of the same closed-set condition that checkOpen() reports as 'ResultSet closed'. The set is closed by close() or by next() after an invalid step. Any column read on a closed set throws this.

Solutions

  1. Read columns only while a successful next() (or hasLastStepReturnedRow() after execute()) says a row is current
  2. Guard shared result sets with isOpen() before reading
  3. Discard the set after catching any step error and re-execute

Example fix

// before
Object v = rs.get(1); // set closed earlier -> 'ResultSet is not open'

// after
if (rs.isOpen() && rs.hasLastStepReturnedRow()) {
  Object v = rs.get(1);
}
Defensive patterns

Strategy: validation

Validate before calling

if (rs.isOpen() && rs.hasLastStepReturnedRow()) {
  Object v = rs.get(1);
}

Try / catch

try {
  return rs.get(1);
} catch (SQLException e) {
  // closed-set condition; fix lifecycle ownership rather than catching repeatedly
  throw new IllegalStateException("column read on closed result set", e);
}

Prevention

When it happens

Trigger: Calling rs.get(...) or any accessor that delegates to get(int) after close(), or after an invalid-state step auto-closed the set; reading columns after next() returned false and an error path closed the set.

Common situations: Reading row data outside the while (rs.next()) loop; helper methods closing sets early; continuing after a swallowed step error.

Related errors


AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20). Data as JSON: /api/errors/a79464652e857ab0. Report an issue: GitHub.

Appendix: source

Thrown at bindings/java/src/main/java/tech/turso/core/TursoResultSet.java:161

  public void close() throws SQLException {
    this.open = false;
  }

  public Object get(String columnName) throws SQLException {
    final int columnsLength = this.columnNames.length;
    for (int i = 0; i < columnsLength; i++) {
      if (this.columnNames[i].equals(columnName)) {
        return get(i + 1);
      }
    }

    throw new SQLException("column name " + columnName + " not found");
  }

  public Object get(int columnIndex) throws SQLException {
    if (!this.isOpen()) {
      throw new SQLException("ResultSet is not open");
    }

    if (this.lastStepResult == null || this.lastStepResult.getResult() == null) {
      throw new SQLException("ResultSet is null");
    }

    final Object[] resultSet = this.lastStepResult.getResult();
    if (columnIndex > resultSet.length || columnIndex < 0) {
      throw new SQLException("columnIndex out of bound");
    }

    return resultSet[columnIndex - 1];
  }

  public String[] getColumnNames() {
    return this.columnNames;
  }

View on GitHub (pinned to 244cde92a7)