Yes MySQL
always thow and catch the SQLException
in the execution method. what you have to do is to catch the SQLException
in your execution method, them throw new MySQLIntegrityConstraintViolationException
public void executeQuery() {
try {
// code
rs = pstmt.executeQuery();
} catch (SQLException ex) {
throw new MySQLIntegrityConstraintViolationException(ex);
}
so in the outer method that called the execute method, it should catch only the MySQLIntegrityConstraintViolationException
catch (MySQLIntegrityConstraintViolationException ex) {
//handle ex
}