Skip to content

Instantly share code, notes, and snippets.

@Alcar32
Created May 15, 2013 23:16
Show Gist options
  • Save Alcar32/5588187 to your computer and use it in GitHub Desktop.
Save Alcar32/5588187 to your computer and use it in GitHub Desktop.
Print SQLException Example
static void errorPrint(Throwable e) {
if (e instanceof SQLException)
SQLExceptionPrint((SQLException)e);
else
System.out.println("A non-SQL error: " + e.toString());
}
static void SQLExceptionPrint(SQLException sqle) {
while (sqle != null) {
System.out.println("\n---SQLException Caught---\n");
System.out.println("SQLState: " + (sqle).getSQLState());
System.out.println("Severity: " + (sqle).getErrorCode());
System.out.println("Message: " + (sqle).getMessage());
sqle.printStackTrace();
sqle = sqle.getNextException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment