Solved Problem importing rows from database

Discussion in 'Plugin Development' started by wouterrr, Nov 2, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    wouterrr

    Hey guys,

    I'm working on a method which loads in the lobbies from the database but I'm kinda stuck. I used this method but for some reason it doesnt go through the while loop. I didn't get any errors in the console.
    Code:java
    1. public void loadLobbies() {
    2. /** Create the statement and execute the query **/
    3.  
    4. try {
    5. s = con.createStatement();
    6. rs = s.executeQuery("SELECT * FROM lobby");
    7. if (!(rs.next())) {
    8. this.plugin.getLogger().info("No lobbies to load in.");
    9. }
    10. while (rs.next()) {
    11. /** New instance of Lobby **/
    12. Lobby l = new Lobby(rs.getInt("lobbyid"), rs.getInt("maxplayers"),
    13. rs.getString("spawnlocation"),
    14. Boolean.parseBoolean(rs.getString("onlyvip")), rs.getString("mapname"),
    15. plugin);
    16. // lets add the lobby to the general list
    17. this.plugin.getLogger().info("Loaded in lobby: " + l.getId());
    18. Init.vars.lobbies.add(l);
    19. }
    20. } catch (Exception e) {
    21. e.printStackTrace();
    22. }
    23. }


    I hope someone can help me :)
    Thanks in advance!

    Wouter
     
  2. Offline

    wouterrr

    Fixed this by removing if (!(rs.next())){ etc..
     
Thread Status:
Not open for further replies.

Share This Page