我正在尝试执行 sql 查询:
INSERT INTO celebrity (name, `1`, `15`, `3`, `20`, `4`, `13`, `35`, `22`, `6`, `19`) VALUES ("Keith Allen", 1, 1, 1, 1, 1, -1, -1, -1, -1, 1)
它在工作台中工作正常并正确添加了新行,但是当我使用executeUpdate(String query)方法从java调用相同的查询时,我收到sql语法错误
最佳答案
您需要像这样转义双引号:
INSERT INTO celebrity (name, `1`, `15`, `3`, `20`, `4`, `13`, `35`, `22`, `6`, `19`)
VALUES (\"Keith Allen\", 1, 1, 1, 1, 1, -1, -1, -1, -1, 1)
关于java - mySQL 查询在 java 中给出语法错误,但在 mySQL Workbench 中工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29340015/