Code example for SQLException

Methods: getErrorCode, getMessage, getSQLState

0
public class SQLExceptionReader implements ExceptionReader 
{ 
    public String getMessage(Throwable t)
    { 
        SQLException e = (SQLException) t;
        return e.getMessage() + "(SQL Code: " + e.getErrorCode() + ", SQL State: + " + e.getSQLState() + ")";
    } 
 
    public Throwable getCause(Throwable t)
    { 
        SQLException e = (SQLException) t;
        Throwable cause = e.getNextException();
        if (cause == null)
        { 
            cause = e.getCause();
        } 
        return cause;
    } 
 
    public Class<?> getExceptionType()
    {