{"record":{"id":"c451af4dd2b06f5b","repo":"tursodatabase/turso","slug":"sqlite-only-supports-type-forward-only-cursors","errorCode":null,"errorMessage":"SQLite only supports TYPE_FORWARD_ONLY cursors","messagePattern":"SQLite only supports TYPE_FORWARD_ONLY cursors","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"bindings/java/src/main/java/tech/turso/core/TursoConnection.java","lineNumber":160,"sourceCode":"  // TODO: check whether this is still valid for turso\n  /**\n   * Checks whether the type, concurrency, and holdability settings for a {@link ResultSet} are\n   * supported by the SQLite interface. Supported settings are:\n   *\n   * <ul>\n   *   <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.","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/java/src/main/java/tech/turso/core/TursoConnection.java#L142-L178","documentation":"checkCursor() enforces the only result-set type the engine supports: TYPE_FORWARD_ONLY (rows stream once, no scrolling). createStatement(type, ...) or prepareStatement(sql, type, ...) with any other type throws immediately before execution.","triggerScenarios":"Calling createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ...) or prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ...); frameworks requesting scrollable result sets (e.g. Hibernate scrollable results, some reporting tools).","commonSituations":"Porting an app from a JDBC driver that supports scrolling (MySQL/PostgreSQL); ORM pagination configured for scroll-insensitive cursors; IDE-generated JDBC boilerplate with non-default constants.","solutions":["Use the no-arg createStatement()/prepareStatement(sql) or pass TYPE_FORWARD_ONLY explicitly","For pagination, rewrite as SQL: LIMIT/OFFSET or keyset (WHERE id > ? ORDER BY id LIMIT n)","If you truly need scrolling, materialize rows into a cache and navigate in memory"],"exampleFix":"// before\nStatement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);\n\n// after\nStatement st = conn.createStatement(); // defaults to forward-only, read-only","handlingStrategy":"validation","validationCode":"// normalize before creating statements\nint type = resultSetType == ResultSet.TYPE_FORWARD_ONLY ? resultSetType : ResultSet.TYPE_FORWARD_ONLY;\nif (resultSetType != ResultSet.TYPE_FORWARD_ONLY) {\n  LOG.warn(\"scrollable result sets unsupported; downgraded to TYPE_FORWARD_ONLY\");\n}\nStatement st = conn.createStatement(type, ResultSet.CONCUR_READ_ONLY);","typeGuard":null,"tryCatchPattern":"try {\n  return conn.createStatement(reqType, ResultSet.CONCUR_READ_ONLY);\n} catch (SQLException e) {\n  if (e.getMessage().contains(\"TYPE_FORWARD_ONLY\")) return conn.createStatement(); // retry with default\n  throw e;\n}","preventionTips":["Default to the no-arg createStatement()/prepareStatement(sql) — it already uses the supported combination","Configure ORMs/frameworks (e.g. Hibernate) to non-scrollable, LIMIT/OFFSET pagination","Encapsulate statement creation in one helper so unsupported constants are caught in one place"],"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"}