Index: jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveStatement.java =================================================================== --- jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveStatement.java +++ jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveStatement.java @@ -202,12 +202,19 @@ */ public int executeUpdate(String sql) throws SQLException { + if (isClosed) { + throw new SQLException("Can't execute after statement has been closed"); + } + try { + resultSet = null; client.execute(sql); + } catch (HiveServerException e) { + throw new SQLException(e.getMessage(), e.getSQLState(), e.getErrorCode()); } catch (Exception ex) { - throw new SQLException(ex.toString()); + throw new SQLException(ex.toString(), "08S01"); } - throw new SQLException("Method not supported"); + return 0; } /* Index: jdbc/src/test/org/apache/hadoop/hive/jdbc/TestJdbcDriver.java =================================================================== --- jdbc/src/test/org/apache/hadoop/hive/jdbc/TestJdbcDriver.java +++ jdbc/src/test/org/apache/hadoop/hive/jdbc/TestJdbcDriver.java @@ -346,6 +346,16 @@ doTestSelectAll(tableName, 100, 20); } + public final void testExecuteUpdate() throws Exception { + Statement stmt = con.createStatement(); + + int result = stmt.executeUpdate("CREATE TABLE exec_update_test_table(x INT)"); + assertEquals(0, result); + + result = stmt.executeUpdate("DROP TABLE exec_update_test_table"); + assertEquals(0, result); + } + public void testDataTypes() throws Exception { Statement stmt = con.createStatement();