score:0

try {
    ...
} catch (dataaccessexception ex) {
    if (ex.getrootcause() instanceof sqlexception) {
        sqlexception sqlex = (sqlexception) ex.getrootcause();
        int errorcode = sqlex.geterrorcode();
        if (errorcode == -20017) {
            ...
        }
    }
}

Related Query