{"record":{"id":"d8693f1fe70c9091","repo":"tursodatabase/turso","slug":"invalid-transaction-isolation-level-level","errorCode":null,"errorMessage":"Invalid transaction isolation level: ${level}","messagePattern":"Invalid transaction isolation level: (.+?)","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"bindings/java/src/main/java/tech/turso/core/TursoConnection.java","lineNumber":301,"sourceCode":"   *     Connection.TRANSACTION_READ_UNCOMMITTED}, {@code Connection.TRANSACTION_READ_COMMITTED},\n   *     {@code Connection.TRANSACTION_REPEATABLE_READ}, or {@code\n   *     Connection.TRANSACTION_SERIALIZABLE}.\n   * @throws SQLException if a database access error occurs, this method is called on a closed\n   *     connection or the given parameter is not one of the {@code Connection} constants\n   */\n  public void setTransactionIsolation(int level) throws SQLException {\n    synchronized (transactionLock) {\n      checkOpen();\n\n      if (inTransaction) {\n        throw new SQLException(\"Cannot change isolation level while transaction is active.\");\n      }\n\n      if (level != Connection.TRANSACTION_READ_UNCOMMITTED\n          && level != Connection.TRANSACTION_READ_COMMITTED\n          && level != Connection.TRANSACTION_REPEATABLE_READ\n          && level != Connection.TRANSACTION_SERIALIZABLE) {\n        throw new SQLException(\"Invalid transaction isolation level: \" + level);\n      }\n\n      this.transactionIsolation = level;\n    }\n  }\n\n  /**\n   * Retrieves the current transaction isolation level.\n   *\n   * @return the current transaction isolation level\n   * @throws SQLException if a database access error occurs or the connection is closed\n   */\n  public int getTransactionIsolation() throws SQLException {\n    checkOpen();\n    return transactionIsolation;\n  }\n\n  /**","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/java/src/main/java/tech/turso/core/TursoConnection.java#L283-L319","documentation":"TursoConnection.setTransactionIsolation() only accepts the four java.sql.Connection constants: TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE. Any other int (custom value, vendor-specific constant, or garbage from config) is rejected.","triggerScenarios":"Passing a database-specific constant such as a vendor snapshot-isolation value (e.g. 4096), an arbitrary int like 8, or a config-derived number that failed to parse into one of the four accepted constants (0, 1, 2, 4, 8).","commonSituations":"Porting isolation settings from SQL Server/Oracle constant tables; typos in YAML/properties files (transcation_serializable, wrong numeric); mapping code that reads another database's metadata and forwards it verbatim.","solutions":["Use Connection.TRANSACTION_SERIALIZABLE — SQLite/Turso effectively serialize writers, so it is the accurate value","Validate the value against the four constants before calling setTransactionIsolation","Check the config source for typos or values carried over from a previous database"],"exampleFix":"// before\nconn.setTransactionIsolation(4096); // vendor constant from an old SQL Server app\n\n// after\nconn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);","handlingStrategy":"validation","validationCode":"private static final Set<Integer> SUPPORTED = Set.of(\n    Connection.TRANSACTION_READ_UNCOMMITTED,\n    Connection.TRANSACTION_READ_COMMITTED,\n    Connection.TRANSACTION_REPEATABLE_READ,\n    Connection.TRANSACTION_SERIALIZABLE);\n\nif (!SUPPORTED.contains(level)) {\n  throw new IllegalArgumentException(\"Unsupported isolation level: \" + level);\n}\nconn.setTransactionIsolation(level);","typeGuard":"static boolean isValidIsolationLevel(int level) {\n  return level == Connection.TRANSACTION_READ_UNCOMMITTED\n      || level == Connection.TRANSACTION_READ_COMMITTED\n      || level == Connection.TRANSACTION_REPEATABLE_READ\n      || level == Connection.TRANSACTION_SERIALIZABLE;\n}","tryCatchPattern":null,"preventionTips":["Only ever pass java.sql.Connection.TRANSACTION_* constants — never raw ints or vendor constants","Map config strings to the constants yourself and fail fast on unknown values","Default to TRANSACTION_SERIALIZABLE for SQLite-compatible engines"],"tags":["java","jdbc","transaction","isolation","config","bindings"],"backgroundTag":"invalid-transaction-isolation-level","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}