Some of the very useful ones in SQLException are :
Real Chaining Support
SQLException now supports additional constructors with the "cause" specified as argument. The causal relationship can now be used extensively to program chaining of exceptions. Here is a snipped adopted from Lance.
catch(SQLException ex) {
while(ex != null) {
Throwable t = ex.getCause();
while(t != null) {
System.out.println("Cause:" + t);
t = t.getCause();
}
ex = ex.getNextException();
}
}
Categorization
Two distinct categories of SQLExceptions will be supported - SQLTransientException and SQLNonTransientException. SQLNonTransientException is more of a runtime exception (would have loved to see it derived from RuntimeException though) where retry will not help, unless the problem is explicitly rectified. The classes included as SQLNonTransientException are
- SQLFeatureNotSupportedException
- SQLNonTransientConnectionException
- SQLDataException
- SQLIntegrityConstraintViolationException
- SQLInvalidAuthorizationException
- SQLSyntaxErrorException
SQLTransientException is more of a checked exception with the following subclasses
- SQLTransientConnectionException
- SQLTransactionRollbackException
- SQLTimeoutException
For more details on the advances in JDBC 4.0 features refer to this artima article.
No comments:
Post a Comment