code: public boolean isConstraintError(SQLException e) {
          if (e != null) {
              String sqlstate = e.getSQLState();
              if (sqlstate != null) {
                  return sqlstate.startsWith(SQLSTATE_CONSTRAINT_VIOLATION_CLASS_CODE);
              }
          }
          return false;
      }
docs: Examines the SQLSTATE code of the given SQL exception and determines if
  it is a generic constaint violation.