在下面标记的行上出现Parameter index out of range (1 > number of parameters, which is 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();
答案 0 :(得分:6)
您缺少端口列的匹配转义符:
`port
应该是
`port`