开发者

i got ibfk_5 when trying input forreign key to table

I have structure table like this.

alt text http://img709.imageshack.us/img709/3315/stucture.png

the problem is :

When i want to input data to "index" table. I got this error.

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (test.index, CONSTRAINT index_ibfk_5 FOREIGN KEY (b_FK) REFEREN开发者_如何学GoCES b (Id_B))

When i remove the relation index and b. it's working fine.

i using same way for a_Fk, and c_Fk. but only b_FK which have problem.

Anyone know how to solve this? thx b4

FYI : i using java, net bean 6.8, mySql (Xampp V.3.2.0.1)


You are inserting a value in column b_FK of table index that does not exist in table b, Id_B column.

Perhaps you should make sure to insert data in tables a, b, and c and only then in index. Also, if your b_FK column is something like not null default 0, change it to accept null for whenever you need to save a row to index table with an empty b_FK.

As extraneon said in his comment, it always help to provide more data, we can't guess these details ourselves.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜