Java SQLException mergeException(List exceptions)

Here you can find the source of mergeException(List exceptions)

Description

merge Exception

License

Apache License

Declaration

public static SQLException mergeException(List<SQLException> exceptions) 

Method Source Code


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

import java.sql.SQLException;
import java.util.ArrayList;

import java.util.List;

public class Main {
    public static StackTraceElement split = new StackTraceElement("------- one sql exceptions-----", "", "", 0);

    public static SQLException mergeException(List<SQLException> exceptions) {
        // return new OneToManySQLExceptionsWrapper(exceptions);
        SQLException first = exceptions.get(0);
        List<StackTraceElement> stes = new ArrayList<StackTraceElement>(30 * exceptions.size());
        // stes.addAll(Arrays.asList(first.getStackTrace()));
        boolean hasSplit = false;
        for (StackTraceElement ste : first.getStackTrace()) {
            stes.add(ste);//from  w w  w  .  ja  v  a2  s . c o  m
            if (ste == split) {
                hasSplit = true;
            }
        }
        if (!hasSplit) {
            stes.add(split);
        }
        SQLException current = null;
        for (int i = 1, n = exceptions.size(); i < n; i++) {
            // newEx.setNextException(exceptions.get(i));
            // current.setNextException(exceptions.get(i));
            current = exceptions.get(i);
            // stes.addAll(Arrays.asList(exceptions.get(i).getStackTrace()));
            hasSplit = false;
            for (StackTraceElement ste : current.getStackTrace()) {
                stes.add(ste);
                if (ste == split) {
                    hasSplit = true;
                }
            }
            if (!hasSplit) {
                stes.add(split);
            }
        }
        // newEx.getCause();
        first.setStackTrace(stes.toArray(new StackTraceElement[stes.size()]));
        return first;
    }
}

Related

  1. isXJ015Error(Throwable exception)
  2. log(Logger logger, SQLException e)
  3. log(SQLException e, Logger log)
  4. logAll(Log log, SQLException e)
  5. logSqlError(SQLException ex, Logger logger)
  6. mergeException(List exceptions)
  7. mergeSQLExceptionMsg(final StringBuilder msgBuilder, final SQLException e, final String prefix)
  8. oracleSessionHasBeenKilled(Exception exception)
  9. parseRemoteException(Throwable t)