あなたが持っているならJdbcTemplate
、あなたはすることができます
catch (SqlException e) {
throw jdbcTemplate.getExceptionTranslator().translate("my task", null, e);
}
を持っていない場合JdbcTemplate
は、JdbcTemplate.getExceptionTranslator()
メソッドのソース コードを見てください。
public synchronized SQLExceptionTranslator getExceptionTranslator() {
if (this.exceptionTranslator == null) {
DataSource dataSource = getDataSource();
if (dataSource != null) {
this.exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator(dataSource);
}
else {
this.exceptionTranslator = new SQLStateSQLExceptionTranslator();
}
}
return this.exceptionTranslator;
}
そして、その動作を模倣します:-)