MYSQL列与第1行的值不匹配

时间:2016-11-04 13:39:18

标签: java mysql bukkit

我遇到插入表的问题:下面是我在更新代码时得到的警告。

[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)

以上是我的代码。

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())
                    + "')");
}

1 个答案:

答案 0 :(得分:1)

你有10列

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

但发送11个值

"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