SHARE
TWEET

Untitled

a guest May 19th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   @Override
  2.   public void delete(Local local) throws SQLException {
  3.     final String req =
  4.       "DELETE FROM api_locaux WHERE id_local=?";
  5.     PreparedStatement stmt = connection.prepareStatement(req);
  6.     stmt.setInt(1, local.getIdLocal());
  7.     try {
  8.       int result = stmt.executeUpdate();
  9.       // Si aucune ligne n'a été mise à jour, on n'a pas trouvé le local.
  10.       if(result == 0) {
  11.         throw new SQLException(
  12.           "Identifiant de local non trouvé, aucune ligne effacée"
  13.         );
  14.       }
  15.     }
  16.     catch (SQLIntegrityConstraintViolationException icve) {
  17.       throw new SQLException("Ce record ne peut pas être supprimé car il est lié à d'autres records");
  18.     }
  19.     finally {
  20.       stmt.close();
  21.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top