我似乎遇到了一个障碍。我正在为我的世界 bukkit 服务器创建一个“经济”系统。
我试图先按“最富有”来订购桌子,但是收到的订单是不同的。当我通过 phpMyAdmin 运行 SQL 时,它以正确的顺序接收
public static HashMap<String, Double> topPlayers(String economyKey) {
sql.build("SELECT b.balance, p.username FROM " + sql.prefix
+ "players p INNER JOIN " + sql.prefix + "balances b ON p.id=b.user_id WHERE economy_key=? ORDER BY b.balance DESC LIMIT 0,5");
String[] params = { economyKey };
ResultSet results = sql.executePreparedQuery(params);
HashMap<String, Double> players = new HashMap<String, Double>();
try {
while (results.next()) {
players.put(results.getString("username"), results.getDouble("balance"));
}
} catch (SQLException e) {
e.printStackTrace();
}
return players;
}