Java SQLException printExceptions(OutputStream os, SQLException sqlEx)

Here you can find the source of printExceptions(OutputStream os, SQLException sqlEx)

Description

Print an exception, or series of exceptions to the designated output stream.

License

Apache License

Parameter

Parameter Description
os The output stream to print to.
sqlEx The exception(s) to print.

Declaration

public static void printExceptions(OutputStream os, SQLException sqlEx) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.OutputStream;
import java.io.PrintWriter;

import java.sql.SQLException;

public class Main {
    /**/* w  ww.ja v  a 2 s . c  o  m*/
     * 
     * Print an exception, or series of exceptions to the designated output
     * stream.
     * 
     * @param os
     *          The output stream to print to.
     * @param sqlEx
     *          The exception(s) to print.
     * 
     * 
     */
    public static void printExceptions(OutputStream os, SQLException sqlEx) {
        PrintWriter pw = new PrintWriter(os, true);
        while (sqlEx != null) {
            pw.println("----------------------------------------------");
            pw.println("ERROR CODE : " + sqlEx.getErrorCode());
            pw.println("ERROR STATE: " + sqlEx.getSQLState());
            sqlEx.printStackTrace(pw);
            sqlEx = sqlEx.getNextException();
        }
    }
}

Related

  1. mergeException(List exceptions)
  2. mergeSQLExceptionMsg(final StringBuilder msgBuilder, final SQLException e, final String prefix)
  3. oracleSessionHasBeenKilled(Exception exception)
  4. parseRemoteException(Throwable t)
  5. printExceptionAndRollback(Connection conn, Exception e)
  6. printSQLException(SQLException e)
  7. printSQLException(SQLException e)
  8. printSQLException(SQLException ex)
  9. printSQLException(SQLException ex)