{"record":{"id":"c74c45a11a6a51d7","repo":"t8y2/dbx","slug":"transactions-are-not-supported-by-this-jdbc-driver","errorCode":null,"errorMessage":"Transactions are not supported by this JDBC driver","messagePattern":"Transactions are not supported by this JDBC driver","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"agents/common/src/main/java/com/dbx/agent/TransactionExecutor.java","lineNumber":61,"sourceCode":"        StatementRunner runner\n    ) {\n        return executeStatements(conn, statements, schema, setSchemaSql, () -> \"\", runner);\n    }\n\n    public static QueryResult executeStatements(\n        Connection conn,\n        List<String> statements,\n        String schema,\n        Function<String, String> setSchemaSql,\n        Supplier<String> resetSchemaSql,\n        StatementRunner runner\n    ) {\n        return unchecked(() -> {\n            long start = System.currentTimeMillis();\n            if (!supportsTransactions(conn)) {\n                // An explicit transaction request must not degrade to auto-commit:\n                // callers rely on it to avoid partial writes when a later statement fails.\n                throw new UnsupportedOperationException(\"Transactions are not supported by this JDBC driver\");\n            }\n\n            boolean savedAutoCommit = conn.getAutoCommit();\n            conn.setAutoCommit(false);\n            try {\n                long totalAffected = executeAll(conn, statements, schema, setSchemaSql, resetSchemaSql, runner);\n                conn.commit();\n                return result(totalAffected, start);\n            } catch (Exception e) {\n                conn.rollback();\n                throw e;\n            } finally {\n                conn.setAutoCommit(savedAutoCommit);\n            }\n        });\n    }\n\n    private static long executeAll(","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/common/src/main/java/com/dbx/agent/TransactionExecutor.java#L43-L79","documentation":"TransactionExecutor.executeStatements() checks whether the JDBC connection supports transactions (DatabaseMetaData.supportsTransactions) before starting one. If the driver reports transactions as unsupported, it throws UnsupportedOperationException instead of silently running the statements in auto-commit mode. This is deliberate: callers depend on the explicit transaction to get all-or-nothing writes, so degrading would risk partial writes.","triggerScenarios":"Calling executeStatements/executeUpdateStatements with a Connection whose driver reports supportsTransactions()==false — e.g. a connection over a driver/wrapper that does not implement transactions (some streaming bridges, certain read-only or no-transaction datasources, custom driver wrappers).","commonSituations":"Pointing the agent at a non-transactional JDBC driver or a wrapper (pooling/proxy driver, CSV/file-based driver) that reports no transaction support; misconfigured datasource where the wrong driver class is loaded; embedded or test drivers that skip transaction support.","solutions":["Use a JDBC driver/database that supports transactions (the driver currently in use reports supportsTransactions()==false).","Verify the driver class/URL in the datasource config — a wrong fallback driver may have been selected (e.g. a generic bridge instead of the real vendor driver).","If writes do not need atomicity, use a non-transactional execution path (execute statements individually in auto-commit) instead of the transaction executor.","Catch UnsupportedOperationException and surface a clear configuration error to the user rather than retrying."],"exampleFix":"// before\nTransactionExecutor.executeStatements(conn, statements, schema, setSchemaSql, resetSchemaSql, runner); // throws on non-transactional driver\n// after\nif (!conn.getMetaData().supportsTransactions()) {\n    throw new IllegalStateException(\n        \"Datasource driver \" + conn.getMetaData().getDriverName() + \" does not support transactions; \" +\n        \"configure a transaction-capable driver for multi-statement writes\");\n}\nTransactionExecutor.executeStatements(conn, statements, schema, setSchemaSql, resetSchemaSql, runner);","handlingStrategy":"validation","validationCode":"if (!conn.getMetaData().supportsTransactions()) {\n    throw new IllegalStateException(\"Driver \" + conn.getMetaData().getDriverName() + \" cannot run transactional multi-statement writes\");\n}","typeGuard":"static boolean supportsTransactions(Connection conn) throws SQLException {\n    return conn.getMetaData().supportsTransactions();\n}","tryCatchPattern":"try {\n    TransactionExecutor.executeStatements(conn, statements, schema, setSchemaSql, resetSchemaSql, runner);\n} catch (UnsupportedOperationException e) {\n    throw new SQLException(\"Transactional execution unavailable: \" + e.getMessage() +\n        \". Configure a transaction-capable JDBC driver.\", e);\n}","preventionTips":["Verify DatabaseMetaData.supportsTransactions() when configuring a datasource","Avoid generic/bridge JDBC drivers for write workloads; use the vendor driver","Do not mix auto-commit assumptions with transactional execution paths","Fail fast at connection setup if transaction support is required by your app"],"tags":["transactions","jdbc","unsupported-operation","atomicity"],"backgroundTag":"transactions-not-supported","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}