Skip to content

Commit 259682e

Browse files
committed
Return proper error when user tries to enable transactions
Transactions are not supported, so `setAutoCommit(false)` should fail, as it does not provide the isolation or rollback-ability requested by the caller. `commit()` and `rollback()` should fail in auto-commit mode (this is what PostgreSQL JDBC driver does).
1 parent 5ca9485 commit 259682e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/ClickHouseConnectionImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ public String nativeSQL(String sql) throws SQLException {
209209

210210
@Override
211211
public void setAutoCommit(boolean autoCommit) throws SQLException {
212-
212+
if (autoCommit) {
213+
return;
214+
}
215+
throw new SQLFeatureNotSupportedException("Transactions are not supported");
213216
}
214217

215218
@Override
@@ -219,12 +222,12 @@ public boolean getAutoCommit() throws SQLException {
219222

220223
@Override
221224
public void commit() throws SQLException {
222-
225+
throw new SQLException("Cannot commit when auto-commit is enabled");
223226
}
224227

225228
@Override
226229
public void rollback() throws SQLException {
227-
230+
throw new SQLException("Cannot commit when auto-commit is enabled");
228231
}
229232

230233
@Override

0 commit comments

Comments
 (0)