Created
May 15, 2013 23:16
-
-
Save Alcar32/5588187 to your computer and use it in GitHub Desktop.
Print SQLException Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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