diff --git beeline/src/java/org/apache/hive/beeline/Commands.java beeline/src/java/org/apache/hive/beeline/Commands.java index da896a7a58..bcbc574918 100644 --- beeline/src/java/org/apache/hive/beeline/Commands.java +++ beeline/src/java/org/apache/hive/beeline/Commands.java @@ -304,6 +304,7 @@ public boolean dropall(String line) { try { rs.close(); } catch (Exception e) { + beeLine.error(e); } } // run as a batch @@ -787,6 +788,7 @@ public HiveConf getHiveConfHelper(boolean call) { private BufferedRows getConfInternal(boolean call) { Statement stmnt = null; BufferedRows rows = null; + ResultSet rs = null; try { boolean hasResults = false; DatabaseConnection dbconn = beeLine.getDatabaseConnection(); @@ -803,19 +805,26 @@ private BufferedRows getConfInternal(boolean call) { } } if (hasResults) { - ResultSet rs = stmnt.getResultSet(); + rs = stmnt.getResultSet(); rows = new BufferedRows(beeLine, rs); } } catch (SQLException e) { beeLine.error(e); } finally { - if (stmnt != null) { + if (rs != null) { try { - stmnt.close(); + rs.close(); } catch (SQLException e1) { beeLine.error(e1); } } + if (stmnt != null) { + try { + stmnt.close(); + } catch (SQLException e2) { + beeLine.error(e2); + } + } } return rows; } @@ -1428,7 +1437,6 @@ public boolean exit(String line) { public boolean closeall(String line) { if (close(null)) { while (close(null)) { - ; } return true; }