请允许我在jsp servlet中捕获重复的条目错误。这是我的密码
Insert Ignore into(…)
catch(SQLException E){
if(e instanceof SQLIntegrityConstraintViolationException e){
message= “Warning: “ + e.getMessage();
}
}发布于 2022-08-12 11:52:13
} catch (SQLException e) {
if (e instanceof SQLIntegrityConstraintViolationException) {
message = “Warning: “ + e.getMessage();
}
}或者更诚实地说,在地毯下抹去一个例外:
} catch (SQLIntegrityConstraintViolationException e) {
message = “Warning: “ + e.getMessage();
} catch (SQLException e2) {
}您不需要SQLIntegrityConstraintViolationException变量。你可能会把它当成
((SQLIntegrityConstraintViolationException)e).getMessage()https://stackoverflow.com/questions/73333457
复制相似问题