Bonsoir à toute la communauté, voici un moment que je bute sur cette erreur. Au fait je veux faire des enregistrements dans une table contenant une clé étrangère.
voici le code au niveau du DAO :
Code : Sélectionner tout - Visualiser dans une fenêtre à part 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
code au niveau du package service:j'ai créé une class model:
Code : Sélectionner tout - Visualiser dans une fenêtre à part 
2
3
4
5
6
7
Code : Sélectionner tout - Visualiser dans une fenêtre à part 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Code : Sélectionner tout - Visualiser dans une fenêtre à part 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Quand j'essaie de faire un enregistrement je reçois cette erreur:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`bd_projet`.`vehicule`, CONSTRAINT `fk_vehicule_typevehicule1` FOREIGN KEY (`typevehicule_idtypevehicule`) REFERENCES `typevehicule` (`idtypevehicule`) ON DELETE CASCADE ON UPDATE CASCADE)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1041)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2441)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2366)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2350)
at ci.objis.projet3.dao.VehiculeDao.create(VehiculeDao.java:58)
at ci.objis.projet3.dao.VehiculeDao.create(VehiculeDao.java:1)
at ci.objis.projet3.service.VehiculeService.ajouter(VehiculeService.java:15)
at ci.objis.projet3.service.VehiculeService.ajouter(VehiculeService.java:1)
at ci.objis.projet3.model.VehiculeModel.addVehicule(VehiculeModel.java:100)
at ci.objis.projet3.iu.AddVehicule$2.actionPerformed(AddVehicule.java:172)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)

 

 
		
		 
         
 

 
			
			


 
			 
   
 


 Cannot add or update a child
 Cannot add or update a child
				 Répondre avec citation
  Répondre avec citation
Partager