tursodatabase/turso · error · java.sql.SQLException

turso only supports CLOSE_CURSORS_AT_COMMIT

Error message

turso only supports CLOSE_CURSORS_AT_COMMIT

What it means

JDBC4Connection.setHoldability() rejects any holdability mode other than ResultSet.CLOSE_CURSORS_AT_COMMIT (value 2). Turso result sets are materialized and forward-only, so cursors never survive a commit, and the driver hard-rejects HOLD_CURSORS_AT_COMMIT (value 1) at JDBC4Connection.java:180. getHoldability() always returns 2, so the accepted configuration is simply 'never set holdability'.

Solutions

  1. Remove the setHoldability() call entirely - turso's default (CLOSE_CURSORS_AT_COMMIT) is the only supported mode.
  2. If a pool forces holdability, configure it to leave the driver default or explicitly set CLOSE_CURSORS_AT_COMMIT (2).
  3. In shared code, guard the call: only set holdability when the value equals ResultSet.CLOSE_CURSORS_AT_COMMIT.
  4. If you genuinely need cursors open across commits, turso cannot serve that access pattern - restructure to fetch data before committing.

Example fix

// before
conn.setHoldability(ResultSet.HOLD_CURSORS_AT_COMMIT); // throws

// after
// holdability is always CLOSE_CURSORS_AT_COMMIT in turso; just do not set it
// or explicitly:
conn.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT);
Defensive patterns

Strategy: validation

Validate before calling

int desired = ResultSet.HOLD_CURSORS_AT_COMMIT;
if (desired != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
    // skip setting holdability; turso only supports CLOSE_CURSORS_AT_COMMIT
} else {
    conn.setHoldability(desired);
}

Try / catch

try {
    conn.setHoldability(holdability);
} catch (SQLException e) {
    if (e.getMessage().contains("CLOSE_CURSORS_AT_COMMIT")) {
        // holdability unsupported; proceed with driver default
    } else { throw e; }
}

Prevention

When it happens

Trigger: connection.setHoldability(ResultSet.HOLD_CURSORS_AT_COMMIT); connection.setHoldability(1); pools or frameworks that push a default holdability onto every connection (DBCP2 defaultHoldability, some Spring test configurations); code ported from PostgreSQL/Oracle where hold-over-commit cursors are normal.

Common situations: HikariCP/DBCP2 datasource properties copied from another database that include holdability settings; application-server connection factories that set all JDBC options uniformly; framework startup code that 'normalizes' connection properties and fails fast on turso; integration tests reused across databases.

Related errors


AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20). Data as JSON: /api/errors/02410cbf6bed5213. Report an issue: GitHub.

Appendix: source

Thrown at bindings/java/src/main/java/tech/turso/jdbc4/JDBC4Connection.java:180

  @Override
  public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
    synchronized (this) {
      this.typeMap = map;
    }
  }

  @Override
  public int getHoldability() throws SQLException {
    connection.checkOpen();
    return ResultSet.CLOSE_CURSORS_AT_COMMIT;
  }

  @Override
  public void setHoldability(int holdability) throws SQLException {
    connection.checkOpen();
    if (holdability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
      throw new SQLException("turso only supports CLOSE_CURSORS_AT_COMMIT");
    }
  }

  @Override
  @SkipNullableCheck
  public Savepoint setSavepoint() throws SQLException {
    throw new SQLFeatureNotSupportedException("Savepoints are not supported by Turso");
  }

  @Override
  @SkipNullableCheck
  public Savepoint setSavepoint(String name) throws SQLException {
    throw new SQLFeatureNotSupportedException("Savepoints are not supported by Turso");
  }

  @Override
  public void rollback(Savepoint savepoint) throws SQLException {
    throw new SQLFeatureNotSupportedException("Savepoints are not supported by Turso");

View on GitHub (pinned to 244cde92a7)