Description
context
Often a constraint exception is something "special" to catch. The current JDBC driver (deeper checked with 7.4.1) seems to have no straight forward way to do so.
preferred solution
Instead of wrapping this error in a SQLServerException
(which sub-classes java.sql.SQLException
) raise an SQLIntegrityConstraintViolationException
(which sub-classes the same, since Java 1.6), likely also wrapped for SQL-Server.
alternatives I've considered
Check if the already catched SQLException
is an instance of SQLServerException
, if it is: check the error code and handle the correct magic number accordingly, otherwise throw the original exception.
side-question
What is the currently best way to check for this?
also likely applies to other standard SQLExceptions/Errors
SQLInvalidAuthorizationSpecException
,SQLTransientConnectionException
, SQLNonTransientConnectionException
, SQLSyntaxErrorException
, SQLTransactionRollbackException
Metadata
Metadata
Assignees
Type
Projects
Status