PreparedStatement stup = con.prepareStatement(
        "UPDATE TrailerLocationMaster" +
        "SET Block = ?, Location = ?, Day = NOW(), SetTime = NOW(), Comment = ?" +
        "Where Trailer = ?;");

stup.setString(1, BlockName);
stup.setString(2, LocationName);
stup.setString(3, text);
stup.setString(4, TrailerName);
stup.addBatch();

stup.executeBatch();


有人可以解释为什么我遵循SQL教程时出现语法错误

最佳答案

您在每行末尾缺少空格:

"UPDATE TrailerLocationMaster " +
                       //    ^ added space
"SET Block = ?, Location = ?, Day = NOW(), SetTime = NOW(), Comment = ? " +
                                                                  //   ^ added space
"Where Trailer = ?;");

09-26 06:28