Making a small modular process in Java. However when i call the SQL statements from my website the system comes back with the error:
java.sql.SQLSyntaxErrorException: Syntax error: Encountered ";" at line 8, column 2.
Below is the first few lines of the SQL file in question as well as the system im using for retrieving the data.
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")
);
...
Retrieval Script:
InputStream in = new URL("http://db.*******.com/derby/version1.00.sql").openStream();
return org.apache.commons.io.IOUtils.toString(in);
It does not make sense as to how a syntax error can be generated from a place where a semicolon is supposed to be.
Yes you'll need to split the string into individual statements and run each separately:
String[] createTableStatements = allStatements.Split...
for (String createStatement : createTableStatements) {
try (Statement ps = connection.createStatement()) {
ps.executeUpdate(createStatement);
}
}