public static void printStackTrace(SQLException e,PrintWriter pw){
  SQLException next=e;
  while (next != null) {
    next.printStackTrace(pw);
    next=next.getNextException();
    if (next != null) {
      pw.println("Next SQLException:");
    }
  }
}

public static void printStackTrace ( SQLException e , PrintWriter pw ) { SQLException next = e ; while ( next != null ) { next . printStackTrace ( pw ) ; next = next . getNextException ( ) ; if ( next != null ) { pw . println ( "Next SQLException:" ) ; } } }
print the stack trace for a sqlexception to a specified printwriter .
