Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do we capture what the SQLCODE And/Or SQLSTATE

 
David Coulthard
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21955
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. getSQLState is what I was looking for.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!