{"record":{"id":"a1bea34f4e465daf","repo":"tursodatabase/turso","slug":"the-result-set-is-not-open","errorCode":null,"errorMessage":"The result set is not open","messagePattern":"The result set is not open","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"bindings/java/src/main/java/tech/turso/core/TursoResultSet.java","lineNumber":53,"sourceCode":"\n  public static TursoResultSet of(TursoStatement statement) {\n    return new TursoResultSet(statement);\n  }\n\n  private TursoResultSet(TursoStatement statement) {\n    this.open = true;\n    this.statement = statement;\n  }\n\n  /**\n   * Consumes all the rows in this {@link ResultSet} until the {@link #next()} method returns\n   * `false`.\n   *\n   * @throws SQLException if the result set is not open or if an error occurs while iterating.\n   */\n  public void consumeAll() throws SQLException {\n    if (!open) {\n      throw new SQLException(\"The result set is not open\");\n    }\n\n    while (next()) {}\n  }\n\n  /**\n   * Moves the cursor forward one row from its current position. A {@link TursoResultSet} cursor is\n   * initially positioned before the first fow; the first call to the method <code>next</code> makes\n   * the first row the current row; the second call makes the second row the current row, and so on.\n   * When a call to the <code>next</code> method returns <code>false</code>, the cursor is\n   * positioned after the last row.\n   *\n   * <p>Note that turso only supports <code>ResultSet.TYPE_FORWARD_ONLY</code>, which means that the\n   * cursor can only move forward.\n   *\n   * @return true if the new current row is valid; false if there are no more rows\n   * @throws SQLException if a database access error occurs\n   */","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/java/src/main/java/tech/turso/core/TursoResultSet.java#L35-L71","documentation":"TursoResultSet.consumeAll() requires the set to be open. open becomes false when close() is called, when a previous next() hit an invalid step state (next() sets open = false before throwing), or when the owning statement was closed/reset (reset() replaces the ResultSet entirely).","triggerScenarios":"Calling consumeAll() after rs.close(), after a SQLException from next() already closed the set, or on the statement's result set after TursoStatement.reset() created a fresh one.","commonSituations":"Cleanup code that drains unread result sets in finally blocks after an earlier error; re-running a statement and draining the stale pre-reset ResultSet; interleaved usage of two result sets from one statement.","solutions":["Check rs.isOpen() before calling consumeAll()","Treat any earlier SQLException from next() as terminal — the set is already closed and must not be drained","Re-execute the statement if you need a fresh, open ResultSet"],"exampleFix":"// before\nrs.close();\nrs.consumeAll(); // throws: The result set is not open\n\n// after\nif (rs.isOpen()) {\n  rs.consumeAll();\n}","handlingStrategy":"validation","validationCode":"if (rs.isOpen()) {\n  rs.consumeAll();\n}","typeGuard":null,"tryCatchPattern":"try {\n  rs.consumeAll();\n} catch (SQLException e) {\n  if (\"The result set is not open\".equals(e.getMessage())) {\n    // already drained or closed — nothing to do\n  } else {\n    throw e;\n  }\n}","preventionTips":["Only call consumeAll() immediately after execution, before any close()","Treat any SQLException from next() as having closed the set — never drain afterwards","After stmt.reset(), use the new getResultSet(), not the old reference"],"tags":["java","jdbc","resultset","lifecycle","bindings"],"backgroundTag":"resultset-already-closed","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}