我有这样的代码。
try {
st = Session.getDbConnection().createStatement();
delSt = Session.getDbConnection().createStatement();
rs = st.executeQuery("SELECT msg_id,message,mobile_no FROM sms");
while (rs.next()) {
delSt.executeUpdate("DELETE FROM sms WHERE msg_id = '" + rs.getString(1) + "'");
System.out.println("Message sent");
}
Session.getDbConnection().commit();
} catch (Exception ex) {
if (ex.getMessage().startsWith("error occurred at recursive")){
}
else{
logger.error(ex.getMessage(), ex);
}
try {
if (rs != null) {
rs.close();
}
if (st != null) {
st.close();
}
if (delSt != null) {
delSt.close();
}
} catch (Exception ex1) {
logger.error(ex1.getMessage(), ex1);
ex1.printStackTrace();
}
try {
if (!Session.getDbConnection().isClosed()) {
Session.getDbConnection().close();
}
} catch (Exception ex1) {
logger.error("ERROR:Closing Database Connection:" + ex.getMessage(), ex);
}
} finally {
}
现在在这种情况下,我想忽略/避免日志的异常“错误发生在递归 SQL 级别 1”。但我想记录除此异常之外的其他内容。我的代码有什么问题。谢谢