Java SQLException printSQLException(SQLException e)

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

Description

print SQL Exception

License

Open Source License

Declaration

public static void printSQLException(SQLException e) 

Method Source Code

//package com.java2s;
/*//from w ww  .ja  v  a  2s.c  o m
 * This file is part of WaqtSalat-Service.
 * 
 * WaqtSalat-Service is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * WaqtSalat-Service is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with WaqtSalat-Service. If not, see <http://www.gnu.org/licenses/>.
 */

import java.sql.SQLException;

public class Main {
    public static void printSQLException(SQLException e) {
        String format = "%-12s : %s\n";
        while (e != null) {
            String errMsg = "------------- SQLException ----------------\n";
            errMsg += String.format(format, "SQL State", e.getSQLState());
            errMsg += String.format(format, "Error Code", e.getErrorCode());
            errMsg += String.format(format, "Cause", e.getCause());
            errMsg += String.format(format, "Message", e.getMessage());
            System.err.print(errMsg);
            // for stack traces, refer to derby.log or uncomment this:
            // e.printStackTrace(System.err);
            System.err.println("--------------------------------------------\n");
            e = e.getNextException();
        }
    }
}

Related

  1. mergeSQLExceptionMsg(final StringBuilder msgBuilder, final SQLException e, final String prefix)
  2. oracleSessionHasBeenKilled(Exception exception)
  3. parseRemoteException(Throwable t)
  4. printExceptionAndRollback(Connection conn, Exception e)
  5. printExceptions(OutputStream os, SQLException sqlEx)
  6. printSQLException(SQLException e)
  7. printSQLException(SQLException ex)
  8. printSQLException(SQLException ex)
  9. printSqlException(SQLException sqlex)