Java Code Examples for java.sql.SQLException#getStackTrace()

The following examples show how to use java.sql.SQLException#getStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SQLCloseables.java    From phoenix with Apache License 2.0 6 votes vote down vote up
@Override
public StackTraceElement[] getStackTrace() {
    if (!this.hasSetStackTrace) {
        ArrayList<StackTraceElement> frames = new ArrayList<StackTraceElement>(this.exceptions.size() * 20);
        
        int exceptionNum = 0;
        for (SQLException exception : this.exceptions) {
            StackTraceElement header = new StackTraceElement(MultipleCausesSQLException.class.getName(), 
                    "Exception Number " + exceptionNum, 
                    "<no file>",
                    0);
            
            frames.add(header);
            for (StackTraceElement ste : exception.getStackTrace()) {
                frames.add(ste);
            }
            exceptionNum++;
        }
        
        setStackTrace(frames.toArray(new StackTraceElement[frames.size()]));
        this.hasSetStackTrace = true;
    }        
    
    return super.getStackTrace();
}
 
Example 2
Source File: SQLCloseables.java    From phoenix with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public StackTraceElement[] getStackTrace() {
    if (!this.hasSetStackTrace) {
        ArrayList<StackTraceElement> frames = new ArrayList<StackTraceElement>(this.exceptions.size() * 20);
        
        int exceptionNum = 0;
        for (SQLException exception : this.exceptions) {
            StackTraceElement header = new StackTraceElement(MultipleCausesSQLException.class.getName(), 
                    "Exception Number " + exceptionNum, 
                    "<no file>",
                    0);
            
            frames.add(header);
            for (StackTraceElement ste : exception.getStackTrace()) {
                frames.add(ste);
            }
            exceptionNum++;
        }
        
        setStackTrace(frames.toArray(new StackTraceElement[frames.size()]));
        this.hasSetStackTrace = true;
    }        
    
    return super.getStackTrace();
}