gpt4 book ai didi

java - MySQL 语法错误 |您的 SQL 语法有错误;

转载 作者:行者123 更新时间:2023-12-02 03:01:06 27 4
gpt4 key购买 nike

错误:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'lock WHERE player='SrLolok'' at line 1

代码:

PreparedStatement search = instance.getConnection().prepareStatement("SELECT * FROM lock WHERE player=?;");
search.setString(1, player);
ResultSet rs = search.executeQuery();

最佳答案

lockreserved word in MySQL .

如果要使用它,需要用反引号括起来:

SELECT * FROM `lock` WHERE player=?

或者更好的是,使用与保留字不对应的表名,这样您就不必担心这一点。

关于java - MySQL 语法错误 |您的 SQL 语法有错误;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59953353/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com