Results 1 to 4 of 4
  1. #1
    losintikfos is offline Member
    Join Date
    Nov 2008
    Posts
    4
    Rep Power
    0

    Default Cannot insert duplicate key row in object

    Hi Experts;

    I am iterating through a Site Object and using the elements values to populate a solution object.

    During the iteration process i do encounter duplicates values in the List and hence the exception below when attempt insert:

    PHP Code:
    com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert duplicate key row in object 'dbo.solutionscustinfo' with unique index 'i1'.
    	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(Unknown Source)
    	at com.billing.essensys.ws.ServiceSync.SolutionCustSyncOne(ServiceSync.java:452)
    	at com.billing.essensys.ws.ServiceSync.Run(ServiceSync.java:505)
    	at com.billing.essensys.ws.ServiceSync.main(ServiceSync.java:511)
    Do anyone know how to control these duplication?

  2. #2
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    6

    Default

    This is more of a database question than Java, but you're the "id" column is unique. You will get a database error if you try to insert 2 entries with the same value in a unique column, for example your "id" having multiple entries with value 1. And if that's not what's happening with your program, then I don't know

  3. #3
    ron87 is offline Member
    Join Date
    Mar 2009
    Posts
    52
    Rep Power
    0

    Default

    it is primary key violation problem

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Quote Originally Posted by ron87 View Post
    it is primary key violation problem
    Not necessarily. You can have unique indexes without them being primary keys, and the error itself does not mention "primary key". And the OP already knew it was a unigue index problem.

Similar Threads

  1. Counting Duplicate Variables in an Array
    By Npcomplete in forum New To Java
    Replies: 2
    Last Post: 10-24-2008, 07:33 PM
  2. Avoid/Eliminate Duplicate Code
    By kicker in forum New To Java
    Replies: 6
    Last Post: 09-11-2008, 04:14 AM
  3. How to insert java Object in oracle database
    By Thilkumar82 in forum Advanced Java
    Replies: 9
    Last Post: 08-13-2008, 11:33 AM
  4. concate all duplicate line in a file.
    By vaskarbasak in forum Advanced Java
    Replies: 0
    Last Post: 06-02-2008, 12:49 PM
  5. random string are duplicate
    By googgoo in forum New To Java
    Replies: 3
    Last Post: 04-03-2008, 10:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •