【问题标题】:My update sql query keeps saying syntax error but I cant tell what it is我的更新 sql 查询一直说语法错误,但我不知道它是什么
【发布时间】:2015-09-07 12:01:32
【问题描述】:
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 教程操作时出现语法错误

【问题讨论】:

  • 如果能解决您的问题,别忘了将答案标记为已接受

标签: java sql ms-access-2007


【解决方案1】:

您在每行末尾缺少空格:

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

【讨论】:

    【解决方案2】:

    您的查询字符串是

    UPDATE TrailerLocationMasterSET Block = ?, Location = ?, Day = NOW(), SetTime =  NOW(), Comment = ?Where Trailer = ?;
    

    请注意,TrailerLocationMaster 和 SET 之间以及 ?和在哪里。

    纠正它们,它应该可以工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-04
      相关资源
      最近更新 更多