{"record":{"id":"e57a8c21211be3e5","repo":"tursodatabase/turso","slug":"resultset-is-null","errorCode":null,"errorMessage":"ResultSet is null","messagePattern":"ResultSet is null","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"bindings/java/src/main/java/tech/turso/core/TursoResultSet.java","lineNumber":165,"sourceCode":"\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\n  public void setColumnNames(String[] columnNames) {\n    this.columnNames = columnNames;\n  }\n","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/java/src/main/java/tech/turso/core/TursoResultSet.java#L147-L183","documentation":"get(int) requires a current row: lastStepResult must be non-null and hold a row payload. It is null when next() never ran (note TursoStatement.execute() steps once internally), and getResult() is null when the cursor is past the last row or the result is empty. In short: reading a column with no row under the cursor.","triggerScenarios":"Calling rs.get(1) before any rs.next(); reading after next() returned false; reading after execute() reported no rows; reading an empty result set.","commonSituations":"Missing if (rs.next()) guard around reads; code assuming execute() leaves the cursor on row 1; re-reading values after the iteration loop completed; SELECT COUNT-style queries where the developer assumed a row exists unconditionally.","solutions":["Always guard reads with the iteration: if (rs.next()) { Object v = rs.get(1); }","Use hasLastStepReturnedRow() to confirm a row is present before optional reads","Treat next() == false as 'no data' and skip value extraction entirely"],"exampleFix":"// before\nrs.get(1); // no next() called yet -> ResultSet is null\n\n// after\nif (rs.next()) {\n  Object v = rs.get(1);\n}","handlingStrategy":"validation","validationCode":"if (rs.next()) {          // cursor now sits on a real row\n  Object v = rs.get(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call get(...) before a successful next() — including after execute() returned false","Standard shape: if (rs.next()) { read } else { handle empty }","Use hasLastStepReturnedRow() when you need to confirm a row without stepping again"],"tags":["java","jdbc","resultset","iteration","bindings"],"backgroundTag":"resultset-before-first-next","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}