Spring 将 java.sql.SQLException 翻译为 DataAccessException
你好。 由于我似乎无法在我的 dao 中使用 spring DataAccessException 转换机制,因此我想知道是否可以
Internal Exception: java.sql.SQLException: [BEA][Oracle JDBC Driver][Oracle]ORA-00001: unique constraint (JSP_OWN.IDX_MC_CC_RAPPORTI_02) violated
手动将其转换为 DataAccessException 层次结构。
亲切的问候 马西莫
Hallo.
Since it seems that I cannot use the spring DataAccessException translation mechanism in my dao, I would like to know if it possible to translate the
Internal Exception: java.sql.SQLException: [BEA][Oracle JDBC Driver][Oracle]ORA-00001: unique constraint (JSP_OWN.IDX_MC_CC_RAPPORTI_02) violated
to the DataAccessException hierarchy manually.
Kind regards
Massimo
如果你有
JdbcTemplate
,你可以这样做如果你没有
JdbcTemplate
,只需查看JdbcTemplate.getExceptionTranslator()
的源代码方法:并模仿它的行为:-)
If you have a
JdbcTemplate
, you can doIf you do not have
JdbcTemplate
, just look at the source code of theJdbcTemplate.getExceptionTranslator()
method:And mimic it's behaviour :-)