未知的SQL错误

时间:2014-04-07 22:20:47

标签: mysql sql sqlite

我正在创建一个表并产生SQL错误,我看不出原因。

    statement.executeUpdate("drop table if exists group");
    String group = "CREATE TABLE group" +
         "(groupId INT PRIMARY KEY NOT NULL, " + 
         "groupLeader INT NOT NULL, " + 
         "groupMembers INT NOT NULL, " + 
         "goals INT NOT NULL)";
    statement.executeUpdate(group);

1 个答案:

答案 0 :(得分:3)

GROUP是保留字。试试:

statement.executeUpdate("drop table if exists `group`");
    String group = "CREATE TABLE `group`" +
         "(groupId INT PRIMARY KEY NOT NULL, " + 
         "groupLeader INT NOT NULL, " + 
         "groupMembers INT NOT NULL, " + 
         "goals INT NOT NULL)";
    statement.executeUpdate(group);