Catch all the rows of a query

1

Friends, I have a problem: I need to get each rows in a query with a loop. I saw a code in StackOverflow, but it does not work. Who knows how, please let me know.

Follow the code:

ResultSet rs = conn.prepareStatement("SELECT * FROM 'rankups'").executeQuery();

             do {

                 String nick = rs.getString("nick");
                 String rank = rs.getString("rank");
                 UUID uuid = Bukkit.getOfflinePlayer(nick).getUniqueId();
                 Rankupbr.DATA_YAML.set(uuid.toString(), rank);

                } while (rs.next());
    
asked by anonymous 13.07.2017 / 03:16

1 answer

0

Try this:

ResultSet rs = conn.prepareStatement("SELECT * FROM 'rankups'").executeQuery();

         while(rs.next()) {

             String nick = rs.getString("nick");
             String rank = rs.getString("rank");
             UUID uuid = Bukkit.getOfflinePlayer(nick).getUniqueId();
             Rankupbr.DATA_YAML.set(uuid.toString(), rank);

            }
    
13.07.2017 / 14:55