Bonjour tous le monde :
J'essaye de supprimer une ligne de ma table avec la méthode executeUpdate
mais ça marche pas voici on code :
mais il m'affiche l'erreur suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 public static void supprimerClient(int num) { try { Class.forName("com.mysql.jdbc.Driver"); java.sql.Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/fezsaiss","root",""); Statement state = conn.createStatement(); int deleteLine = state.executeUpdate("DELETE FROM Client WHERE Num='"+num+"'"); } catch (Exception e) { e.printStackTrace(); } }
et Merci d'avance.
Code : Sélectionner tout - Visualiser dans une fenêtre à part com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`fezsaiss`.`client_has_vols`, CONSTRAINT `fk_Client_has_Vols_Client` FOREIGN KEY (`Client_Num`) REFERENCES `client` (`Num`) ON DELETE NO ACTION ON UPDATE NO ACTION)
Partager