[Updated Thread] SQL Help

Discussion in 'Plugin Development' started by PandazNWafflez, May 30, 2012.

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

    PandazNWafflez

    Right. So the SQL execute method from a statement is a boolean type.

    So if I execute:

    "SELECT " + name + " FROM Players";

    Then how do I actually get the thing I selected? This might be a bit of a noob question.
     
  2. Offline

    I_am_not_funny

    while(resultsetvariable.next()) {
    //stuff
    }

    That'll loop through every entry, even if you have just one.
     
  3. Offline

    PandazNWafflez

    Thanks, but I kinda worked out a slightly different way before you posted that. Would this work:

    Code:
    public PlayerData playerFetch(String playerName) {
        ResultSet result = sql.executeQuery("SELECT " + playerName + " FROM Players");
        PlayerData pd;
        try {
            pd = (PlayerData) result.getObject(playerName);
            return pd;
         } catch (SQLException ex) {
             return null;
         }
    }
    
     
  4. Offline

    ZachBora

    You should check if result is empty before end. A thrown error is much slower to process than IF check.
     
Thread Status:
Not open for further replies.

Share This Page