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
什麼可能是錯的?
這將有助於瞭解出現錯誤時設置的值。 – 2012-01-17 15:38:04