Java SQLException printSQLException(SQLException ex)

Here you can find the source of printSQLException(SQLException ex)

Description

print SQL Exception

License

Open Source License

Declaration

public static void printSQLException(SQLException ex) 

Method Source Code


//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*/
                }
            }
        }
    }
}

Related

  1. parseRemoteException(Throwable t)
  2. printExceptionAndRollback(Connection conn, Exception e)
  3. printExceptions(OutputStream os, SQLException sqlEx)
  4. printSQLException(SQLException e)
  5. printSQLException(SQLException e)
  6. printSQLException(SQLException ex)
  7. printSqlException(SQLException sqlex)
  8. printSQLExceptionToErrorLog(Log logger, String message, List sqlExceptions)
  9. printStackTrace(final Throwable exception)