开发者

MySql query exception

When i am trying to insert values in MySQL table through java code, I am getting the exception:

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (icd_app_suite/mapper, CONSTRAINT FK_mapper_1 FOREIGN KEY (user_id) REFERENCES user_detail (user_id) ON DELETE CASCADE 开发者_JAVA百科ON UPDATE CASCADE)

What can be the cause?


The error is clear: you're inserting (or updating) a row which doesn't respect a foreign key in referenced table.
So you first have to insert father record, then child record.
Probably you're adding a record on user_detail table with ID field not present in user table


You are inserting a row with a value in the user_id column that is not found in the user_id column of the user_detail table

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜