aspose file tools*
The moose likes Beginning Java and the fly likes SQLException insight Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "SQLException insight" Watch "SQLException insight" New topic
Author

SQLException insight

Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 660

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.


Jon
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

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:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SQLException insight