Apache Derby - Syntax error: Encountered ";" at line 8, column 2
Apache Derby - Syntax error: Encountered ";" at line 8, column 2
在 Java 中制作一个小的模块化流程。但是,当我从我的网站调用 SQL 语句时,系统返回错误:
java.sql.SQLSyntaxErrorException: Syntax error: Encountered ";" at line 8, column 2.
下面是有问题的 SQL 文件的前几行,以及我用来检索数据的系统。
SQL:
CREATE TABLE "chat_logs"
(
"logId" BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
"logDate" INT DEFAULT NULL,
"logUser" BLOB,
"logMessage" BLOB,
PRIMARY KEY ("logId")
);
CREATE TABLE "configs"
(
"configId" BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
"configType" BLOB,
"configSettings" BLOB,
PRIMARY KEY ("configId")
);
...
检索脚本:
InputStream in = new URL("http://db.*******.com/derby/version1.00.sql").openStream();
return org.apache.commons.io.IOUtils.toString(in);
分号应该在的地方怎么会产生语法错误,这是没有意义的。
是的,您需要将字符串拆分为单独的语句,并且 运行 每个语句分开:
String[] createTableStatements = allStatements.Split...
for (String createStatement : createTableStatements) {
try (Statement ps = connection.createStatement()) {
ps.executeUpdate(createStatement);
}
}
在 Java 中制作一个小的模块化流程。但是,当我从我的网站调用 SQL 语句时,系统返回错误:
java.sql.SQLSyntaxErrorException: Syntax error: Encountered ";" at line 8, column 2.
下面是有问题的 SQL 文件的前几行,以及我用来检索数据的系统。
SQL:
CREATE TABLE "chat_logs"
(
"logId" BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
"logDate" INT DEFAULT NULL,
"logUser" BLOB,
"logMessage" BLOB,
PRIMARY KEY ("logId")
);
CREATE TABLE "configs"
(
"configId" BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
"configType" BLOB,
"configSettings" BLOB,
PRIMARY KEY ("configId")
);
...
检索脚本:
InputStream in = new URL("http://db.*******.com/derby/version1.00.sql").openStream();
return org.apache.commons.io.IOUtils.toString(in);
分号应该在的地方怎么会产生语法错误,这是没有意义的。
是的,您需要将字符串拆分为单独的语句,并且 运行 每个语句分开:
String[] createTableStatements = allStatements.Split...
for (String createStatement : createTableStatements) {
try (Statement ps = connection.createStatement()) {
ps.executeUpdate(createStatement);
}
}