Search in sources :

Example 1 with FBXAException

use of org.firebirdsql.jca.FBXAException in project jaybird by FirebirdSQL.

the class FBSQLException method getSqlErrorCode.

/**
 * Helper method to get the SQL vendor code (or in the case of Firebird: the
 * isc errorcode).
 *
 * @param ex
 *            ResourceException
 * @return isc errorcode, or 0
 */
private static int getSqlErrorCode(ResourceException ex) {
    Throwable cause = resolveCause(ex);
    if (cause instanceof GDSException) {
        return ((GDSException) cause).getIntParam();
    }
    if (cause instanceof SQLException) {
        return ((SQLException) cause).getErrorCode();
    }
    if (cause instanceof FBXAException) {
        FBXAException fbXaException = (FBXAException) cause;
        Throwable cause2 = fbXaException.getCause();
        if (cause2 instanceof SQLException) {
            return ((SQLException) cause2).getErrorCode();
        }
    }
    return 0;
}
Also used : SQLException(java.sql.SQLException) GDSException(org.firebirdsql.gds.GDSException) FBXAException(org.firebirdsql.jca.FBXAException)

Aggregations

SQLException (java.sql.SQLException)1 GDSException (org.firebirdsql.gds.GDSException)1 FBXAException (org.firebirdsql.jca.FBXAException)1