From 4cd1865998a95a79d150bab21eb4850db163de54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=C4=99grzyn?= Date: Sat, 8 Aug 2015 01:07:37 +0200 Subject: [PATCH] HIVE-11293 : Make Connections.setAutoCommit method compliant with the JDBC spec --- jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java index bb2b695..16edd9b 100644 --- a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java +++ b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java @@ -1207,9 +1207,12 @@ public void rollback(Savepoint savepoint) throws SQLException { @Override public void setAutoCommit(boolean autoCommit) throws SQLException { - if (autoCommit) { - throw new SQLException("enabling autocommit is not supported"); + // Per JDBC spec, if the connection is closed a SQLException should be thrown. + if(isClosed) { + throw new SQLException("Connection is closed"); } + // The auto-commit mode is always enabled for this connection. Per JDBC spec, + // if setAutoCommit is called and the auto-commit mode is not changed, the call is a no-op. } /* -- 2.0.1