使用 JDBC 准备好的语句时出现 SQL 1064 语法错误

2023-12-02

I have:

String query = "INSERT INTO Basestations VALUES(?, ?, ?, ?, ?, ?, ?,"
               + "?, ?, ?, ?, ?, ?, ?, ?)";                  


PreparedStatement prep = conn.prepareStatement(query);

prep.setInt(1, profile.getNetworkId());
prep.setInt(2, profile.getBaseStationId());
prep.setInt(8, profile.getLoadLevel());
prep.setInt(11, profile.getPositionX());
prep.setInt(12, profile.getPositionY());
prep.setInt(13, profile.getPort());

prep.setDouble(3, profile.getSignalStrength());
prep.setDouble(4, profile.getFrequency());
prep.setDouble(6, profile.getMaxBitrate());
prep.setDouble(7, profile.getGuaranteedBitrate());
prep.setDouble(10, profile.getRange());

prep.setString(5, profile.getNetworkType());
prep.setString(9, profile.getProvider());
prep.setString(14, profile.getCharging());

prep.setBoolean(15, true);


prep.executeUpdate(query);

我得到:

信息:SQL 异常: 信息:州:42000 信息:消息:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本对应的手册,了解在 '?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' 附近使用的正确语法1号线 信息:错误:1064

可能出什么问题了?


您正在将表示无效 SQL 语句的字符串传递给executeUpdate()方法,当你不需要的时候。尝试只是做prep.executeUpdate();.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 JDBC 准备好的语句时出现 SQL 1064 语法错误 的相关文章

随机推荐