This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC and the fly likes Primary key violation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Primary key violation" Watch "Primary key violation" New topic
Author

Primary key violation

Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 386
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

Joined: Mar 17, 2011
Posts: 8059
    
  22

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

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 386
Hi

the exception in english is



But I don´t why it happens

Any idea?

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18715
    
    8

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

Joined: Mar 17, 2011
Posts: 8059
    
  22

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

Joined: Jun 22, 2005
Posts: 86
You should add one line to check the latest insert rows too.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Primary key violation