aspose file tools*
The moose likes JDBC and the fly likes Handling JDBC Errors in Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Handling JDBC Errors in Exceptions" Watch "Handling JDBC Errors in Exceptions" New topic
Author

Handling JDBC Errors in Exceptions

Nick Delauney
Ranch Hand

Joined: Sep 28, 2002
Posts: 43
Is there a generic way to get the details of an error so that handiling exceptions with custom messages for the user can work across databases?

I have SQL code that could generate a insertion of duplicate primary key SQLException and could generate a duplicate unique id SQLException. I am working with SQL Server, but we will be migrating to DB2 soon.

My thoughts were with getting the SQLException error code, but I think thats particular to databases?


N.D:"Anything worth having, takes time to get"
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30774
    
156

Nick,
Unfortunately you are correct that the code is database specific. Java 5 or 6 (I forget which, but I think it is 6) is supposed to solve this problem by providing more specific SQLException subclasse.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
wood burning stoves
 
subject: Handling JDBC Errors in Exceptions