11
私は実際に例外をキャッチする必要がある場所に出会うまで、すべてが鮮やかです。私はspring jdbcTemplate例外をキャッチする方法は?
jdbcTemplate.query(something...)
try{}
でブロックを置くと私が取得:
Unreachable catch block for SQLException. This exception is never thrown from the try statement body.
私はこのような状況で何をしますか?
try{
personIdReturnedByDb = jdbcTemplate.queryForInt(sql, p.getEmail(),
p.getName(), p.getSurname(), encPw, dateSql);
}
catch(SQLException sa){
}
は
SQLException
、チェック例外は、
JdbcTemplate.query(...)
のいずれかの方法によってスローされていないためだ
SQLExceptionsはありません。 SpringはRuntimeExceptionでそれらをラップします。私はルートクラス名を忘れています。 –
あなたはそれを答えるべきです。 – hvgotcodes