在下面標記的行上獲取錯誤。有任何想法嗎?JDBC給我參數索引超出範圍(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();
你任何機會在其他地方重複使用相同的'statement'變量/其他線程? – 2011-05-05 01:22:29