File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Databases
»
JDBC
Author
How do we capture what the SQLCODE And/Or SQLSTATE
David Coulthard
Greenhorn
Joined: Apr 16, 2008
Posts: 16
posted
Sep 06, 2011 12:13:48
0
The application I'm working on throws the following exception:
org.apache.openjpa.persistence.PersistenceException: DB2 SQL Error: SQLCODE=-803, SQLSTATE=23505
This error occurs when a duplicate key exception is encountered.
My aim is to inspect the error message and act accordingly. i.e.
If (SQLCODE==-803 && SQLSTATE==23505) Do Something(); else ErrorOut ...
How do I get access to the SQLCODE and SQLSTATE so that I can acheive this?
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
2
I like...
posted
Sep 06, 2011 12:17:23
0
David Coulthard wrote:
My aim is to inspect the error message and act accordingly.
Then you're going about it the wrong way. The
SQLException
class has methods which specifically address your requirements. Just use them.
David Coulthard
Greenhorn
Joined: Apr 16, 2008
Posts: 16
posted
Sep 06, 2011 13:53:45
0
Thanks. getSQLState is what I was looking for.
I agree. Here's the link:
http://aspose.com/file-tools
subject: How do we capture what the SQLCODE And/Or SQLSTATE
Similar Threads
Field not found - need help on code
UNIX shell script help
particular SQLCODE bypass in batch mode
DB2 duplicate rows error code
Problem finding objets with composite key
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter