Duplicate key or integrity constraint violation - Mysql

From: FreudianSlip (waynemarrison_at_yahoo.co.uk)
Date: 06/17/04

  • Next message: Peppe: "Using hsql in Eclipse"
    Date: 17 Jun 2004 02:50:05 -0700
    
    

    Hi all,

    I have recently started programming in Java, so forgive me if theres
    something very basic about the problem i'm having.

    I have MySQL 4.0.15 running on linux box quite happily and am using
    Java 1.4.2 and Netbeans 3.6 to access and update the database.

    One table has an autoincrement field (counter) and i get the following
    message when I try to insert a record in the table.

     Duplicate key or integrity constraint violation, message from
    server: "Duplicate entry 'null' for key 1"

    I have tried various ways to perform the insert, using:

    String SQL = "insert into Header values (NULL,'" + getClusterID() +
    "','" .....

    and

    String SQL = "insert into Header values (0, '" + getClusterID() +
    "','" .....

    along with:

    String SQL = "insert into Header (ClusterID,TStamp ...etc ) values
    (getClusterID() + "','" .....

    But still I get the error.

    If I check the table after the program fails, the record has been
    successfully inserted with the correct auto increment figure, however
    of course the program stops dead at that point and does not continue.

    Any help would be much appreciated.

    Thanks

    W


  • Next message: Peppe: "Using hsql in Eclipse"

    Relevant Pages

    • Re: Java and MySql program example ?
      ... > I am trying to learn Java and need an example program with MySql ... > MySql database. ... Database connection established ...
      (comp.lang.java.programmer)
    • Re: OT: Spiegel-Online bei Heise
      ... Aber, wie schon gesagt, so simpel ist die Hardware heute ja nicht mehr, daß es mal eben mit ein paar inb/outb-Befehlen getan ist. ... Java ist in gewissen Bereichen etabliert, ... Wer Word/Excel/Powerpoint haben will, braucht Windows. ... und ein Linux für DSP von Freescale ...
      (de.comp.os.unix.linux.misc)
    • Re: Help me!! Why java is so popular
      ... AIX and Linux currently for Java, C++, C and Perl development. ... The DARK BOWELS of documentation. ... Than you have a full source code of every single ...
      (comp.lang.java.programmer)
    • Re: Which JVM to use under Windows?
      ... I do not have time to get into specifics at the moment. ... Why on earth would you be coding Java using an obsolete ... Microsoft's environment from the day one, ... Linux, and what I found is that they are clunky. ...
      (comp.lang.java.programmer)
    • Re: PcLinux
      ... first instance, we use Java. ... Can't comment on Python because I've never used it. ... Postgresql running on linux works nicely. ... Returning to comments WRT the aesthetics of OS X vs Windows - it's a ...
      (rec.crafts.metalworking)