Skip to content Skip to sidebar Skip to footer

Given A 'java.sql.SQLIntegrityConstraintViolationException' Is It Possible To Determine Column('s) In Error

Given I have an exception of type 'java.sql.SQLIntegrityConstraintViolationException' Is it possible to programmatically determine the column (or columns) in error? I ask this beca

Solution 1:

Quite a bit of this is going to be vendor specific. You can learn a lot from the sql error code. But as the javadoc noted, the value is vendor specific. Spring has a utility which is able to translate these codes (with support for many vendors) into a more specific exception hierarchy. In the case of a constraint violation you would likely get a DataIntegrityViolationException, but that still would not provide explicit access to the index name being violated. The message, however, likely would include the index name.


Post a Comment for "Given A 'java.sql.SQLIntegrityConstraintViolationException' Is It Possible To Determine Column('s) In Error"