Two Laptop Bag*
The moose likes JDBC and the fly likes How to identify the sub type of inetgrity constraint violation programmatically & vendor-neutrally? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to identify the sub type of inetgrity constraint violation programmatically & vendor-neutrally?" Watch "How to identify the sub type of inetgrity constraint violation programmatically & vendor-neutrally?" New topic
Author

How to identify the sub type of inetgrity constraint violation programmatically & vendor-neutrally?

Pad Ven
Ranch Hand

Joined: Apr 29, 2005
Posts: 38
Hi all,
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),

Regards,
TV Padmanabhan
 
jQuery in Action, 2nd edition
 
subject: How to identify the sub type of inetgrity constraint violation programmatically & vendor-neutrally?
 
Similar Threads
Key comparison
Catching PK violations in JDBC
how can an application distinguish between sql errors?
David And Craig - Book Question
CMP insert problem