Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Primary key violation  RSS feed

 
Isaac Ferguson
Ranch Hand
Posts: 1056
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to insert data from a .data file to a database it works the first time but after that it launches an error like



The code is like



Any idea, please?

Thanks
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angus Ferguson wrote:I am trying to insert data from a .data file to a database it works the first time but after that it launches an error like
...
Any idea, please?

I'm afraid my Spanish(?) isn't very good, but why are you trying to apply your .data file more than once?

I suspect it's simply telling you that you're trying to add the same data more than once.
And isn't that a good thing?

Winston
 
Isaac Ferguson
Ranch Hand
Posts: 1056
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

the exception in english is



But I don´t why it happens

Any idea?

Thanks
 
Paul Clapham
Sheriff
Posts: 22199
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My idea is, you should go down the stack trace into the part you didn't show us, until you find a line which refers to your code. It will tell you the line number in your code. Start looking there.
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angus Ferguson wrote:But I don´t why it happens...

And I say again: Aren't you you're trying to add the same data (or perhaps the same key) more than once?

Winston
 
Wei Dai
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should add one line to check the latest insert rows too.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!