• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic