使用PersistenceException
-> SQLException
-> getErrorCode()
,我在日志中隐藏了一个特定的Oracle错误。问题是,在我的server.log
中,我仍然发现以下行:
WARN 25 Sep 2018 12:14:47,121 - id - org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ms 5829302 SQL Error: 13333, SQLState: 72000
ERROR 25 Sep 2018 12:14:47,121 - id - org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ms 5829302 ORA-13333: invalid LRS measure
ORA-06512: at "MDSYS.SDO_LRS", line 3149
ORA-06512: at line 1
不是我专门记录的。
这是我的代码:
try {
try {
//business stuff
} catch (PersistenceException persEx) {
if (persEx.getCause() != null && persEx.getCause() instanceof GenericJDBCException) {
GenericJDBCException jdbcEx = (GenericJDBCException) persEx.getCause();
SQLException sqlEx = (SQLException) jdbcEx.getCause();
if (sqlEx.getErrorCode() == 13333) {
//handling ORA-13333: invalid LRS measure as an info
log.info("Possible invalid LRS measure");
} else {
throw persEx; // do not swallow unhandled exceptions
}
} else {
throw persEx; // do not swallow unhandled exceptions
}
} catch (Exception e) {
log.error("Other exception:" + e.getMessage());
}
} catch (Exception e) {
log.error("Exception to log:" + e.getMessage());
}
答案 0 :(得分:1)
在这种情况下,通过向JBoss
日志处理程序中添加特定的过滤器来解决
<filter-spec value="all(not(match("ORA-13333")), not(match("SQL Error: 13333")))"/>
我希望它对其他人有用。