This week's book giveaway is in the Agile and Other Processes forum. We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line! See this thread for details.
How to identify the sub type of inetgrity constraint violation programmatically & vendor-neutrally?
posted 7 years ago
Can anyone let me know if there is any way to use the SQLIntegrityConstraintViolationException (Java 5 onwards I think) to find out if "unique constraint" (or) "referential integrity constraint i.e. parent key not found" has happened? I have done this in Oracle specific manner and it works but I wish to know if there is a vendor neutral way. I am not using Spring and cannot add support for it in my current application otherwise I could try something like what is mentioned in this URL SpringSource.
I used the SQL error code returned by Oracle (1 for unique constraint, 2291 for referential integrity) because though vendor neutral, the SQL state eems to return 23000 for both types.
Expecting some help from anyone who has succeeded doing it (as that would be cleaner code that writing vendor-specific),