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.
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.