Search code examples
javamysqlbukkit

MYSQL column doesnt match value at row 1


i got problem with insert tables:below is the warning i am getting while updating code.

[14:34:56] [pool-12-thread-1/WARN]: [xmgDrop-1.0.0] An error occurred with given query 'INSERT INTO `xmgdrop_users`(`uuid`, `lastName`, `TURBO_DROP`, `TURBO_EXP`, `pkt`, `lvl`, `exp`, `BLOCKS`, `DISTANCE`, `DROPS`) VALUES (NULL,'dce7d575-81dc-31a8-8f57-b86b6d6b738c','XawierStudio','1478266496028', '1478266496028', '0', '1', '0', '0', '0', 'NULL')'!
[14:34:56] [pool-12-thread-1/WARN]: [xmgDrop-1.0.0] Error: Column count doesn't match value count at row 1
[14:34:56] [pool-12-thread-1/WARN]: java.sql.SQLException: Column count doesn't match value count at row 1
[14:34:56] [pool-12-thread-1/WARN]:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
[14:34:56] [pool-12-thread-1/WARN]:     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
[14:34:56] [pool-12-thread-1/WARN]:     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
[14:34:56] [pool-12-thread-1/WARN]:     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
[14:34:56] [pool-12-thread-1/WARN]:     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
[14:34:56] [pool-12-thread-1/WARN]:     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2620)
[14:34:56] [pool-12-thread-1/WARN]:     at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1662)
[14:34:56] [pool-12-thread-1/WARN]:     at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1581)
[14:34:56] [pool-12-thread-1/WARN]:     at net.xawierstudio.drop.mysql.modes.StoreMySQL$2.run(StoreMySQL.java:89)
[14:34:56] [pool-12-thread-1/WARN]:     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[14:34:56] [pool-12-thread-1/WARN]:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[14:34:56] [pool-12-thread-1/WARN]:     at java.lang.Thread.run(Unknown Source)

and above is my code.

public void insert() {
    Main.getStore().update(false,
            "INSERT INTO `{P}users`(`uuid`, `lastName`, `TURBO_DROP`, `TURBO_EXP`, `pkt`, `lvl`, `exp`, `BLOCKS`, `DISTANCE`, `DROPS`) VALUES (NULL,'"
                    + this.getUuid() + "','" + this.getLastName() + "','" + this.getTURBO_DROP() + "', '"
                    + this.getTURBO_EXP() + "', '" + this.getPkt() + "', '" + this.getLvl() + "', '" + this.getExp()
                    + "', '" + this.getBlocks() + "', '" + this.getDistance() + "', '"
                    + (this.getDrops().isEmpty() ? "NULL"
                            : new StringBuilder("'").append(Util.toString(getDrops())).append("'").toString())
                    + "')");
}

Solution

  • You have 10 columns

    `uuid`, `lastName`, `TURBO_DROP`, `TURBO_EXP`, `pkt`, `lvl`, `exp`, `BLOCKS`, `DISTANCE`, `DROPS`
      1         2            3             4         5      6      7       8           9         10
    

    But send 11 Values

    "VALUES (NULL,'" +                         -- 1
    this.getUuid() + "','" +                   -- 2
    this.getLastName() + "','" +               -- 3 
    this.getTURBO_DROP() + "', '" +            -- 4
    this.getTURBO_EXP() + "', '" +             -- 5
    this.getPkt() + "', '" +                   -- 6
    this.getLvl() + "', '" +                   -- 7 
    this.getExp() + "', '" +                   -- 8 
    this.getBlocks() + "', '" +                -- 9 
    this.getDistance() + "', '" +              -- 10 
    (this.getDrops().isEmpty() ? "NULL" : new  StringBuilder("'").append(Util.toString(getDrops())).append("'").toString()) -- 11