You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
GitMensch
changed the title
[FEATURE REQUEST] separate exception for contraint violation
[FEATURE REQUEST] separate exception for constraint violation
Dec 2, 2019
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-classesjava.sql.SQLException
) raise anSQLIntegrityConstraintViolationException
(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 ofSQLServerException
, 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
The text was updated successfully, but these errors were encountered: