Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * $Id$
  * 
  * Firebird Open Source J2EE Connector - JDBC Driver
  *
  * Distributable under LGPL license.
  * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html
  *
  * This program 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
 * LGPL License for more details.
 *
 * This file was created by members of the firebird development team.
 * All individual contributions remain the Copyright (C) of those
 * individuals.  Contributors to this file are either listed here or
 * can be obtained from a CVS history command.
 *
 * All rights reserved.
 */
package org.firebirdsql.util;
Helper class for building java.sql.SQLException chains.

NOTE: This class is not thread-safe; an instance should only be used on a single thread or with proper external synchronisation.

Parameters:
<E> Type of SQLException (definition: E extends SQLException)
Author(s):
Mark Rotteveel
Since:
2.2
public final class SQLExceptionChainBuilder<E extends SQLException> {
    private E root;
    
    
Create SQLExceptionChainBuilder
    public SQLExceptionChainBuilder() {
        this(null);
    }
    
    
Create SQLExceptionChainBuilder with the specified root exception.

Parameters:
root Root SQLException
    public SQLExceptionChainBuilder(E root) {
        this. = root;
    }
    
    
Appends the passed SQLException to the exception chain.

If this SQLExceptionChainBuilder does not have a root, sqle will be come the root.

Parameters:
sqle SQLException to add to the chain.
Returns:
this SQLExceptionChainBuilder
    public SQLExceptionChainBuilder append(E sqle) {
        if ( == null) {
             = sqle;
        } else {
            .setNextException(sqle);
        }
        return this;
    }
    
    

Returns:
true if this SQLExceptionChainBuilder contains at least one SQLException.
    public boolean hasException() {
        return  != null;
    }
    
    

Returns:
The root SQLException or null if no SQLException was added to this SQLExceptionChainBuilder
    public E getException() {
        return ;
    }
New to GrepCode? Check out our FAQ X