• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException

 
Rahul Naik
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


After executing it shows
*** Error : com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '00008' for key 'PRIMARY'

Please advice
 
Maneesh Godbole
Saloon Keeper
Posts: 11325
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

In future, while posting code, please UseCodeTags. I have added them this time for you. As you can see, the tags make the code much more easier to read and understand.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure if SID or MID is the primary key on this table.
The error message says you have a primary key, this primary key must be unique. But you are trying to insert a second row where the primary key has the value of 00008.
In the stack trace it will tell you which of your SQL statements is the one with the problem. (but you haven't provided us with that just the headline message)
 
Rahul Naik
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sid is the Primary Key
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there are still 2 lines that could be causing this exception...
could you post the full stack trace, or tell us which of the 2 inserts is throwing the exception.

But to be honest the only thing you can actually do is look at the data being returned from the 1st select, is it the data you are expecting?
and the data that is in resultset1 is it what you are expecting?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic