【发布时间】:2021-02-08 04:20:34
【问题描述】:
使用 MacOS - Java - MySql 8.0 - jdbc 8.0 - Intellij。
当我运行 this (Select count(*) from people where id =?;) 替换 ?使用数字 1 可以正常工作。但是当我这样做时:
for (Person person: people) {
int id = person.getId();
checkStmt.setInt(1, id);
ResultSet checkResult = checkStmt.executeQuery(checkSql);
我明白了:
You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near '?' at line 1
运行调试器,数组返回的id值为1。
【问题讨论】:
标签: java mysql intellij-idea