{"record":{"id":"a79464652e857ab0","repo":"tursodatabase/turso","slug":"resultset-is-not-open","errorCode":null,"errorMessage":"ResultSet is not open","messagePattern":"ResultSet is not open","errorType":"exception","errorClass":"java.sql.SQLException","httpStatus":null,"severity":"error","filePath":"bindings/java/src/main/java/tech/turso/core/TursoResultSet.java","lineNumber":161,"sourceCode":"\n  public void close() throws SQLException {\n    this.open = false;\n  }\n\n  public Object get(String columnName) throws SQLException {\n    final int columnsLength = this.columnNames.length;\n    for (int i = 0; i < columnsLength; i++) {\n      if (this.columnNames[i].equals(columnName)) {\n        return get(i + 1);\n      }\n    }\n\n    throw new SQLException(\"column name \" + columnName + \" not found\");\n  }\n\n  public Object get(int columnIndex) throws SQLException {\n    if (!this.isOpen()) {\n      throw new SQLException(\"ResultSet is not open\");\n    }\n\n    if (this.lastStepResult == null || this.lastStepResult.getResult() == null) {\n      throw new SQLException(\"ResultSet is null\");\n    }\n\n    final Object[] resultSet = this.lastStepResult.getResult();\n    if (columnIndex > resultSet.length || columnIndex < 0) {\n      throw new SQLException(\"columnIndex out of bound\");\n    }\n\n    return resultSet[columnIndex - 1];\n  }\n\n  public String[] getColumnNames() {\n    return this.columnNames;\n  }\n","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/java/src/main/java/tech/turso/core/TursoResultSet.java#L143-L179","documentation":"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.","triggerScenarios":"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.","commonSituations":"Reading row data outside the while (rs.next()) loop; helper methods closing sets early; continuing after a swallowed step error.","solutions":["Read columns only while a successful next() (or hasLastStepReturnedRow() after execute()) says a row is current","Guard shared result sets with isOpen() before reading","Discard the set after catching any step error and re-execute"],"exampleFix":"// before\nObject v = rs.get(1); // set closed earlier -> 'ResultSet is not open'\n\n// after\nif (rs.isOpen() && rs.hasLastStepReturnedRow()) {\n  Object v = rs.get(1);\n}","handlingStrategy":"validation","validationCode":"if (rs.isOpen() && rs.hasLastStepReturnedRow()) {\n  Object v = rs.get(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return rs.get(1);\n} catch (SQLException e) {\n  // closed-set condition; fix lifecycle ownership rather than catching repeatedly\n  throw new IllegalStateException(\"column read on closed result set\", e);\n}","preventionTips":["Read columns only inside a while (rs.next()) loop that returned true","One owner for close(); helpers must not close sets they do not own","Discard the set after any step error"],"tags":["java","jdbc","result-set","resource-lifecycle"],"backgroundTag":"result-set-closed","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}