com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '6' for key 'PRIMARY' │···························

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

,

Check whether privilege has the "not null" restriction. If so it always has to have a value and can never be null.

A different reason could be a wrong implementation of a foreign key. Check whether you always correctly insert/update in both tables.

Solutions on the web

via GitHub by ariehkovler
, 10 months ago
Duplicate entry '6' for key 'PRIMARY' │···························
via Stack Overflow by user5655410
, 1 year ago
Cannot add or update a child row: a foreign key constraint fails (`database`.`Comments_Table`, CONSTRAINT `Comments_Table_ibfk_2` FOREIGN KEY (`Reference_ID`) REFERENCES `A_Table` (`A_Table_ID`) ON DELETE CASCADE ON UPDATE CAS)
via GitHub by alanpearce
, 2 years ago
Duplicate entry '4011' for key 'PRIMARY'
via Stack Overflow by arjun narahari
, 2 years ago
Duplicate entry '1' for key 'UK_qk8e1fl454umkjvarmovmdgrp'
via Stack Overflow by Tudor Vintilescu
, 1 year ago
Cannot add or update a child row: a foreign key constraint fails (`comwork`.`test1_child`, CONSTRAINT `test1_child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `Test1` (`id`))
via Stack Overflow by fjtorres
, 2 years ago
Cannot delete or update a parent row: a foreign key constraint fails (`bd_gestionproyectos`.`proyectos_recursos`, CONSTRAINT `FK_proyectos` FOREIGN KEY (`proyecto_id`) REFERENCES `proyectos` (`ID_proyecto`))
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '6' for key 'PRIMARY' │···························
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
at com.mysql.jdbc.Util.getInstance(Util.java:382)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1039)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2111)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2407)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2325)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2310)
at isaac.bastion.storage.Database.execute(Database.java:142)
at isaac.bastion.storage.BastionBlockStorage.saveBastionBlock(BastionBlockStorage.java:77)
at isaac.bastion.storage.BastionBlockStorage.saveBastionBlocks(BastionBlockStorage.java:49)
at isaac.bastion.storage.BastionBlockSet.update(BastionBlockSet.java:111)
at isaac.bastion.storage.BastionBlockSet$1.run(BastionBlockSet.java:45)
at org.bukkit.craftbukkit.v1_7_R1.scheduler.CraftTask.run(CraftTask.java:58)
at org.bukkit.craftbukkit.v1_7_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:345)
at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:614)
at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:273)
at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:562)
at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:469)

Users with the same issue

Samebug visitor profile picture
Unknown user
Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
Once, 5 days ago
Samebug visitor profile picture
Unknown user
Once, 2 years ago
11 times, 4 months ago
70 more bugmates

Know the solutions? Share your knowledge to help other developers to debug faster.