This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android 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: 331
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: 7552
    
  18

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: 331
Hi

the exception in english is



But I don´t why it happens

Any idea?

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    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: 7552
    
  18

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
 
Similar Threads
PreparedStatement fails to execute
into data postgress
JAVA Postgres insert Problem
onetoone unidirectional relationship problem