• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reporting DB status after a SQLException

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
What is the best way to determine what the database status is after a SQLException has occurred.
Eg. Oracle returns the following if you try delete a record with children.
ORA-02292: integrity constraint (ASS_USER.SYS_C001313) violated - child record found
Is there a method call that is not database specific? I need to determine when the above error is occuring, but on any database.
I have tried e.getSQLState() which returns a string '23000'. Can I rely on this?
Thanks in advance
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried the same thing on DB2V5 running on OS/390 and got a 23504.
SQL state is:23504
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0532N A parent row cannot be deleted because the relationship "PRJCTNBR" restricts the deletion. SQLSTATE=23504
The first 2 characters are the class and 23 is Integrity Constraint Violation. Maybe you can use the "23" to indicate children on a delete?
--Amy
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic