Retrieving Exceptions
by , 03-10-2012 at 07:58 AM (599 Views)
The given code outputs the following that is contained in the SQLException or other exception which have been chained to it:
- SQL State
- Error description
- Error Code
- Cause
Java Code:public static void printSQLException(SQLException ex) { for (Throwable e : ex) { if (e instanceof SQLException) { if (ignoreSQLException( ((SQLException)e). getSQLState()) == false) { e.printStackTrace(System.err); System.err.println("SQLState: " + ((SQLException)e).getSQLState()); System.err.println("Error Code: " + ((SQLException)e).getErrorCode()); System.err.println("Message: " + e.getMessage()); Throwable t = ex.getCause(); while(t != null) { System.out.println( "Cause: " + t); t = t.getCause(); } } } } }









Email Blog Entry
Size Reduced for Images in PDF &...
05-15-2013, 05:53 PM in Java Software