Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void supprimer_Livr(ModeleLivr Livr) {
- String id = Livr.getIdLivr();
- String requete = null;
- Connection con=null;
- Statement state;
- String urlmysql;
- try {
- // chargement du pilote
- Class.forName("com.mysql.jdbc.Driver");
- // définition de l'url
- urlmysql="jdbc:mysql://127.0.0.1:3306/gestion_bibliotheque";
- // etablissement de la connexion
- con = DriverManager.getConnection(urlmysql,"root","");
- // création d'une instruction
- requete = "DELETE FROM client" +
- " WHERE Code = ’"+id+"’";
- state = con.createStatement();
- int nbEnregSup = state.executeUpdate(requete);
- if (nbEnregSup == 0){
- JOptionPane.showMessageDialog(null, "Aucune suppression effectuée."
- + " Ce code client n’existe pas.",
- "Vérifiez votre saisie", JOptionPane.ERROR_MESSAGE);
- }
- else {
- state.close();
- JOptionPane.showMessageDialog(null,"Suppression du client code ["
- + id + "] effectuée");
- }
- }
- catch (SQLException e){
- JOptionPane.showMessageDialog(null, "Problème lors de la suppression.",
- "Vérifiez votre saisie", JOptionPane.ERROR_MESSAGE);
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement