{"record":{"id":"12093592de906e40","repo":"tursodatabase/turso","slug":"sqlite-only-supports-closing-cursors-at-commit","errorCode":null,"errorMessage":"SQLite only supports closing cursors at commit","messagePattern":"SQLite only supports closing cursors at commit","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"bindings/java/src/main/java/tech/turso/core/TursoConnection.java","lineNumber":166,"sourceCode":"   *   <li>type: {@link ResultSet#TYPE_FORWARD_ONLY}\n   *   <li>concurrency: {@link ResultSet#CONCUR_READ_ONLY})\n   *   <li>holdability: {@link ResultSet#CLOSE_CURSORS_AT_COMMIT}\n   * </ul>\n   *\n   * @param resultSetType the type setting.\n   * @param resultSetConcurrency the concurrency setting.\n   * @param resultSetHoldability the holdability setting.\n   */\n  public void checkCursor(int resultSetType, int resultSetConcurrency, int resultSetHoldability)\n      throws SQLException {\n    if (resultSetType != ResultSet.TYPE_FORWARD_ONLY) {\n      throw new SQLException(\"SQLite only supports TYPE_FORWARD_ONLY cursors\");\n    }\n    if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {\n      throw new SQLException(\"SQLite only supports CONCUR_READ_ONLY cursors\");\n    }\n    if (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {\n      throw new SQLException(\"SQLite only supports closing cursors at commit\");\n    }\n  }\n\n  /**\n   * Sets the auto-commit mode for this connection.\n   *\n   * <p>When auto-commit is enabled (the default), each SQL statement is committed automatically\n   * upon completion. When auto-commit is disabled, statements are grouped into transactions that\n   * must be explicitly committed or rolled back.\n   *\n   * <p>If this method is called to enable auto-commit while a transaction is active, the current\n   * transaction is committed first.\n   *\n   * @param autoCommit true to enable auto-commit mode; false to disable it\n   * @throws SQLException if a database access error occurs or the connection is closed\n   */\n  public void setAutoCommit(boolean autoCommit) throws SQLException {\n    synchronized (transactionLock) {","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/java/src/main/java/tech/turso/core/TursoConnection.java#L148-L184","documentation":"checkCursor() rejects holdability other than CLOSE_CURSORS_AT_COMMIT: cursors do not survive transaction boundaries in this engine, so requesting HOLD_CURSORS_OVER_COMMIT fails up front. Any result set must be fully consumed or closed before the enclosing transaction commits.","triggerScenarios":"Calling createStatement/prepareStatement with ResultSet.HOLD_CURSORS_OVER_COMMIT as the third parameter; container-managed code (some app servers, pooled wrappers) requesting hold-over-commit by default.","commonSituations":"App servers or connection pools rewriting statement creation with their own holdability; code ported from databases where cursors persist past commit; generated JDBC code with all three constants spelled out.","solutions":["Pass ResultSet.CLOSE_CURSORS_AT_COMMIT or use the overloads without a holdability argument","Consume/close result sets before calling commit() — which the engine requires anyway","Configure the pool/app-server wrapper to preserve default holdability"],"exampleFix":"// before\nStatement st = conn.createStatement(\n    ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);\n\n// after\nStatement st = conn.createStatement(\n    ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT);","handlingStrategy":"validation","validationCode":"int holdability = resultSetHoldability == ResultSet.CLOSE_CURSORS_AT_COMMIT\n    ? resultSetHoldability : ResultSet.CLOSE_CURSORS_AT_COMMIT;\nStatement st = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, holdability);","typeGuard":null,"tryCatchPattern":"try {\n  return conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, requested);\n} catch (SQLException e) {\n  if (e.getMessage().contains(\"closing cursors at commit\")) {\n    return conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT);\n  }\n  throw e;\n}","preventionTips":["Use the two-argument or no-arg statement factory overloads — holdability defaults to the supported value","Fully consume or close result sets before commit(); the engine drops cursors at transaction end regardless","Check pool/app-server wrappers that inject their own holdability when this appears in container code"],"tags":["jdbc","resultset","java"],"backgroundTag":"unsupported-resultset-type","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"}