[ https://issues.apache.org/jira/browse/HIVE-2675?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13176264#comment-13176264 ]
Istvan Szegedi commented on HIVE-2675: -------------------------------------- Could you shed some lights what release exactly you are talking about? In hive 0.8.0 the HiveStatement.java class seems to have executeQuery method, not executeSQL. (./hive/jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveStatement.java) Anyway, the toString() method of the Exception - which is actually inherited from Throwable class - returns the name of the object and the message, as the result of the getMessage() method, concatenated by a colon. Thus when the SQLException is rethrown from the second catch block, the SQLException will have the original message and also the SQLState string value- "08S01". See for instance, a simple code to demonstrate it: import java.sql.SQLException; import java.io.FileReader; public class Exc { public static void main(String[] args) { try { ThrowException(); } catch (SQLException ex) { System.out.println("String: " + ex.toString()); System.out.println("State: " + ex.getSQLState()); System.out.println("Message: " + ex.getMessage()); System.exit(1); } } public static void ThrowException() throws SQLException { try { FileReader fr = new FileReader("test.txt"); } catch (Exception ex) { System.out.println("FileReader exception caught: " + ex.toString()); throw new SQLException(ex.toString(), "08S01"); } } } The output of this code is as follows (the original FileNotFoundException is returned by the rethrown exception and the SQLState can be retrieved, too): FileReader exception caught: java.io.FileNotFoundException: test.txt (No such file or directory) String: java.sql.SQLException: java.io.FileNotFoundException: test.txt (No such file or directory) State: 08S01 Message: java.io.FileNotFoundException: test.txt (No such file or directory) > JDBC SQL execution exception does not contain cause > --------------------------------------------------- > > Key: HIVE-2675 > URL: https://issues.apache.org/jira/browse/HIVE-2675 > Project: Hive > Issue Type: Bug > Components: JDBC > Affects Versions: 0.8.0 > Environment: Any > Reporter: Greg Cottman > > If SQL execution throws an exception in the HiveStatement.executeSQL() method > then it's message is rethrown as a SQLException with a SQLState of "08S01": > 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(), "08S01"); > } > In the case of failed DDL, the exception "ex" has a cause - such as a > java.io.IOException - that contains the actual error text. The description > of the actual problem is lost by failing to include "ex" as the cause in the > new SQLException. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira