dcsimg

Using Java 6, how do you loop through the causes of a SQL Exception?

John Zukowski

The SQLException class is now Iterable in Java 6.

try {

...

} catch (SQLException sqle) {

  for(Throwable t : sqle) {

    System.out.println("Throwable: " + t);

  }

}