List of usage examples for java.sql SQLException setStackTrace
public void setStackTrace(StackTraceElement[] stackTrace)
From source file:com.axibase.tsd.driver.jdbc.strategies.Consumer.java
private static void fillErrors(List<ErrorSection> errorSections, StatementContext context) { SQLException sqlException = null; if (errorSections != null) { for (ErrorSection section : errorSections) { sqlException = new SQLException(section.getMessage(), section.getState()); List<StackTraceElement> list = getStackTrace(section); sqlException.setStackTrace(list.toArray(new StackTraceElement[list.size()])); context.addException(sqlException); }//from w ww . ja v a 2 s . c o m } if (sqlException != null) { throw new AtsdRuntimeException(sqlException.getMessage(), sqlException); } }
From source file:com.taobao.tddl.jdbc.group.util.ExceptionUtils.java
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);/* 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; }