From 0d379a20b47d67b6fc653e927fa0cd41a7920cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=C4=99grzyn?= Date: Sat, 8 Aug 2015 10:27:35 +0200 Subject: [PATCH] HIVE-11501 : Make Connections.setReadOnly method compliant with the JDBC spec --- jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java | 12 ++++++++++-- 1 file changed, 10 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..3b7e004 100644 --- a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java +++ b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java @@ -1279,8 +1279,16 @@ public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLExc @Override public void setReadOnly(boolean readOnly) throws SQLException { - // TODO Auto-generated method stub - throw new SQLException("Method not supported"); + // Per JDBC spec, if the connection is closed a SQLException should be thrown. + if (isClosed) { + throw new SQLException("Connection is closed"); + } + // Per JDBC spec, the request defines a hint to the driver to enable database optimizations. + // The read-only mode for this connection is disabled and cannot be enabled (isReadOnly always returns false). + // The most correct behavior is to throw only if the request tries to enable the read-only mode. + if(readOnly) { + throw new SQLException("Enabling read-only mode not supported"); + } } /* -- 2.0.1