-7
我嘗試爲bukkit創建一個腳本。如果殺死一個殭屍,它需要在mysql表中增加1。怎麼了?或者有另一種方法?JavaInvalid getInt()的值無效
錯誤:java.sql.SQLException中:爲getInt值無效() - 'CraftZombie'
PreparedStatement kills = connection.prepareStatement("SELECT ? FROM `data` WHERE name=?");
kills.setString(1,entity.toString());
kills.setString(2,name);
ResultSet result = kills.executeQuery();
String entity_string = entity.toString();
result.next();
//int score = 1;
//score = result.getInt(1);
//Integer score2 = (Integer) result.getObject(entity_string);
int SC = result.getInt(entity_string);
PreparedStatement stat = connection.prepareStatement("UPDATE data SET ?=? WHERE name=?",
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
stat.setString(1,entity.toString());
stat.setInt(2, SC + 1);
stat.setString(3,name);