我正在创建一个表并产生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);
答案 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);