com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException

Cannot add or update a child row: a foreign key constraint fails (`grades_book_db`.`grades`, CONSTRAINT `FK_Grades_Subject` FOREIGN KEY (`Subject_Id`) REFERENCES `subjects` (`Subject_Id`))


Solutions on the web848

Solution icon of stackoverflow
Cannot add or update a child row: a foreign key constraint fails (`grades_book_db`.`grades`, CONSTRAINT `FK_Grades_Subject` FOREIGN KEY (`Subject_Id`) REFERENCES `subjects` (`Subject_Id`))

Solution icon of web
Cannot add or update a child row: a foreign key constraint fails ( . , CONSTRAINT FOREIGN KEY ( ) REFERENCES ( ))

Solution icon of stackoverflow
Cannot add or update a child row: a foreign key constraint fails (`auction_db`.`user`, CONSTRAINT `ReleBids` FOREIGN KEY (`RelatedBids`) REFERENCES `bids` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE)

Solution icon of github
via GitHub by weiransoft
, 1 year ago
Cannot add or update a child row: a foreign key constraint fails (`rap_db`.`tb_corporation_and_user`, CONSTRAINT `tb_corporation_and_user_ibfk_3` FOREIGN KEY (`role_id`) REFERENCES `tb_role` (`id`))

Solution icon of github
via GitHub by mabouza
, 1 year ago
Cannot add or update a child row: a foreign key constraint fails (`dotcmsslave`.`contentlet`, CONSTRAINT `fk_contentlet_lang` FOREIGN KEY (`language_id`) REFERENCES `language` (`id`))

Solution icon of github
via GitHub by wezell
, 1 year ago
Cannot add or update a child row: a foreign key constraint fails (`dotcms`.`folder`, CONSTRAINT `fk_folder_file_structure_type` FOREIGN KEY (`default_file_type`) REFERENCES `structure` (`inode`))

Solution icon of github
Cannot add or update a child row: a foreign key constraint fails (`dotcms`.`workflow_step`, CONSTRAINT `fk_escalation_action` FOREIGN KEY (`escalation_action`) REFERENCES `workflow_action` (`id`))

Solution icon of googlegroups
via Google Groups by 吴冉波, 7 months ago
Cannot add or update a child row: a foreign key constraint fails (`rizhiyi_system`.`Role_Permission`, CONSTRAINT `fk_role_permission_role_id` FOREIGN KEY (`role_id`) REFERENCES `Role` (`id`) ON DELETE CASCADE)

Solution icon of oraclecommunity
via Oracle Community by Sandeep.R, 1 year ago
Cannot add or update a child row: a foreign key constraint fails (`catalogb`.`dcs_price`, CONSTRAINT `dcs_pricpric_lst_f` FOREIGN KEY (`price_list`) REFERENCES `dcs_price_list` (`price_list_id`))

Solution icon of sourceforge
Cannot add or update a child row: a foreign key constraint fails (`alee/sym_node_identity`, CONSTRAINT `fk_ci_node_id` FOREIGN KEY (`node_id`) REFERENCES `sym_node` (`node_id`))

Stack trace

  • com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`grades_book_db`.`grades`, CONSTRAINT `FK_Grades_Subject` FOREIGN KEY (`Subject_Id`) REFERENCES `subjects` (`Subject_Id`)) 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:425) at com.mysql.jdbc.Util.getInstance(Util.java:408) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3970) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3906) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2524) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2677) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2549) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861) at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2073) at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2009) at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5098) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1994) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:204)

Write tip

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

Users with the same issue

22 times, 1 month ago
2 times, 10 months ago
6 times, 10 months ago
6 times, 10 months ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
64 more bugmates