diff --cc jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java index a74a3a880b,9df5699ce8..0000000000 --- a/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java +++ b/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java @@@ -55,15 -56,16 +56,17 @@@ import java.util.HashMap import java.util.List; import java.util.Map; import java.util.Objects; + import java.util.Optional; /** - * HiveStatement. - * + * The object used for executing a static SQL statement and returning the + * results it produces. */ public class HiveStatement implements java.sql.Statement { - public static final Logger LOG = LoggerFactory.getLogger(HiveStatement.class.getName()); + + private static final Logger LOG = LoggerFactory.getLogger(HiveStatement.class); + public static final String QUERY_CANCELLED_MESSAGE = "Query was cancelled."; private static final int DEFAULT_FETCH_SIZE = HiveConf.ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE.defaultIntVal; @@@ -74,9 -76,8 +77,9 @@@ Map sessConf = new HashMap(); private int fetchSize; private final int defaultFetchSize; - private boolean isScrollableResultset = false; + private final boolean isScrollableResultset; private boolean isOperationComplete = false; + private boolean closeOnResultSetCompletion = false; /** * We need to keep a reference to the result set to support the following: * @@@ -260,17 -219,11 +221,11 @@@ isClosed = true; } - // JDK 1.7 + @Override public void closeOnCompletion() throws SQLException { - throw new SQLFeatureNotSupportedException("Method not supported"); + closeOnResultSetCompletion = true; } - /* - * (non-Javadoc) - * - * @see java.sql.Statement#execute(java.lang.String) - */ - @Override public boolean execute(String sql) throws SQLException { runAsyncOnServer(sql); @@@ -426,7 -373,7 +375,7 @@@ throw e; } catch (Exception e) { isLogBeingGenerated = false; - throw new SQLException(e.toString(), "08S01", e); - throw new SQLException("FAiled to wait for operation to complete", "08S01", e); ++ throw new SQLException("Failed to wait for operation to complete", "08S01", e); } } while (!isOperationComplete); @@@ -758,17 -554,11 +556,11 @@@ return isClosed; } - // JDK 1.7 + @Override public boolean isCloseOnCompletion() throws SQLException { - return false; + return closeOnResultSetCompletion; } - /* - * (non-Javadoc) - * - * @see java.sql.Statement#isPoolable() - */ - @Override public boolean isPoolable() throws SQLException { return false;