This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes How do we capture what the SQLCODE And/Or SQLSTATE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How do we capture what the SQLCODE And/Or SQLSTATE" Watch "How do we capture what the SQLCODE And/Or SQLSTATE" New topic
Author

How do we capture what the SQLCODE And/Or SQLSTATE

David Coulthard
Greenhorn

Joined: Apr 16, 2008
Posts: 16
The application I'm working on throws the following exception:



This error occurs when a duplicate key exception is encountered.

My aim is to inspect the error message and act accordingly. i.e.



How do I get access to the SQLCODE and SQLSTATE so that I can acheive this?

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18109
    
    8

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
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
DB2 duplicate rows error code
Field not found - need help on code
particular SQLCODE bypass in batch mode
UNIX shell script help
Problem finding objets with composite key