JDBC 给我参数索引超出范围(1 > 参数数量,即 0)
下面标记的行上出现参数索引超出范围(1 > 参数数量,即 0)
错误。有什么想法吗?
...
int hash = ConsistantHash.hash(name);
query = "INSERT INTO `server_info` (`host`, `port, `s_port`, `name`, `hash`) VALUES (?, ?, ?, ?, ?)";
statement = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
statement.setString(1, host); //this line
statement.setInt(2, c_port);
statement.setInt(3, s_port);
statement.setString(4, name);
statement.setInt(5, hash);
statement.executeUpdate();
statement.close();
Getting Parameter index out of range (1 > number of parameters, which is 0)
error on the line that is marked below. Any ideas?
...
int hash = ConsistantHash.hash(name);
query = "INSERT INTO `server_info` (`host`, `port, `s_port`, `name`, `hash`) VALUES (?, ?, ?, ?, ?)";
statement = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
statement.setString(1, host); //this line
statement.setInt(2, c_port);
statement.setInt(3, s_port);
statement.setString(4, name);
statement.setInt(5, hash);
statement.executeUpdate();
statement.close();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您缺少端口列的匹配转义:
应该是
You are missing a matching escape of the port column:
Should be