[Updated Thread] SQL Help

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

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


    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


    while(resultsetvariable.next()) {

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


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

    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


    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