Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SQLException insight  RSS feed

 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SQLException

Does the following code block suffice to capture all the stack of exceptions that might be generated from SQLException? How does it work under the hood?
Why is it useful to retrieve .getNextException()?
Can you provide an example where this was useful?



Sourced from Core Java Volume 2 (7th Ed), Chapter 4.
 
Rob Spoor
Sheriff
Posts: 21090
85
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can execute more than one SQL statement at once; either by separating the statements using ; inside the (Prepared)Statement or by using (Prepared)Statement's batch functionality. For instance, it's possible to execute two UPDATE statements at once. Those two statements can each produce their own error. This is done by this form of exception chaining.
For instance:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!