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 web560

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 stackoverflow
via Stack Overflow by nbro
, 1 year ago
Column 'registered_user_username' cannot be null

Solution icon of stackoverflow
Cannot add or update a child row: a foreign key constraint fails (`ibgdb`.`curriculum2`, CONSTRAINT `FK_curriculuns2_curriculuns` FOREIGN KEY (`cpf`) REFERENCES `curriculum` (`cpf`) ON UPDATE CASCADE)

Solution icon of github
via GitHub by Naghtrion
, 10 months ago
Cannot add or update a child row: a foreign key constraint fails (`mc_151`.`mh_Daily`, CONSTRAINT `mh_Daily_Player_Id` FOREIGN KEY (`PLAYER_ID`) REFERENCES `mh_PlayersV2` (`PLAYER_ID`) ON DELETE CASCADE)

Solution icon of github
via GitHub by dav1170
, 1 month ago
Cannot add or update a child row: a foreign key constraint fails (`yamj3`.`cast_crew`, CONSTRAINT `FK_CASTCREW_PERSON` FOREIGN KEY (`person_id`) REFERENCES `person` (`id`))

Solution icon of googlegroups
Cannot add or update a child row: a foreign key constraint fails (`dotcms`.`contentlet_version_info`, CONSTRAINT `fk_contentlet_version_info_working` FOREIGN KEY (`working_inode`) REFERENCES `contentlet` (`inode`))

Solution icon of googlegroups
via Google Groups by Karl Nielsen, 2 months ago
Cannot add or update a child row: a foreign key constraint fails (`casadm`.`serviceticket`, CONSTRAINT `FK7645ADE132A2C0E5` FOREIGN KEY (`ticketGrantingTicket_ID`) REFERENCES `TICKETGRANTINGTICKET` (`ID`))

Solution icon of atlassian
via Atlassian JIRA by Sergei ZH, 1 year ago
Cannot add or update a child row: a foreign key constraint fails (`bassdb`.`ATTACHMENTS`, CONSTRAINT `FK54475F908C38FBEA` FOREIGN KEY (`PAGEID`) REFERENCES `CONTENT` (`CONTENTID`))

Solution icon of stackoverflow
Cannot add or update a child row: a foreign key constraint fails (`test`.`employee_meeting`, CONSTRAINT `FK_EMPLOYEE` FOREIGN KEY (`employee_id`) REFERENCES `employee` (`employee_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, 2 months ago
2 times, 11 months ago
6 times, 1 year ago
6 times, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
66 more bugmates