Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void delete(Local local) throws SQLException {
- final String req =
- "DELETE FROM api_locaux WHERE id_local=?";
- PreparedStatement stmt = connection.prepareStatement(req);
- stmt.setInt(1, local.getIdLocal());
- try {
- int result = stmt.executeUpdate();
- // Si aucune ligne n'a été mise à jour, on n'a pas trouvé le local.
- if(result == 0) {
- throw new SQLException(
- "Identifiant de local non trouvé, aucune ligne effacée"
- );
- }
- }
- catch (SQLIntegrityConstraintViolationException icve) {
- throw new SQLException("Ce record ne peut pas être supprimé car il est lié à d'autres records");
- }
- finally {
- stmt.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement