Here you can find the source of printSQLException(SQLException ex)
public static void printSQLException(SQLException ex)
//package com.java2s; import java.sql.SQLException; public class Main { public static void printSQLException(SQLException ex) { for (Throwable e : ex) { if (e instanceof SQLException) { e.printStackTrace(System.err); System.err.println("SQLState: " + ((SQLException) e).getSQLState()); System.err.println("Error Code: " + ((SQLException) e).getErrorCode()); System.err.println("Message: " + e.getMessage()); Throwable t = ex.getCause(); while (t != null) { System.out.println("Cause: " + t); t = t.getCause();/* w w w . j av a 2s. c o m*/ } } } } }