How do I loop through the causes of a SQL Exception?

John Zukowski

You can repeatedly call getCause() of the SQLException:

try {

...

} catch (SQLException sqle) {

  for(Throwable t : sqle) {

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

    Throwable cause = t.getCause();

    while (cause != null) {

      System.out.println(“Cause: “ + cause);

      cause = cause.getCause();      

    }

  }

}
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact