Grabbing Data - MySQL

Discussion in 'Spigot Plugin Development' started by MangoCodes, May 23, 2016.

  1. So currently my MySQL table includes UUID, PlayerName, Tokens how would I be able to make a method to try to get the players tokens using the UUID Ofc.

    What I have tried:

    Code (Text):

    public void getPlayerTokens(Player p) {
        Connection con = getMySQLConnection();
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery("SELECT * FROM TokenData WHERE TOKENS;");
            if( {
                System.out.println(st.executeQuery("SELECT * FROM TokenData WHERE TOKENS;"));
            }else {
                //Make data for player

        }catch (SQLException e) {
    But that doesn't seen to work....
  2. Any error? And where you have "//Make data for player" print something instead, so you know there is something wrong if your code gets there.
  3. 4chan


    Invalid SQL.

    You want something like:
    SELECT * FROM TokenData WHERE UUID="uuid";
    • Agree Agree x 1
  4. Oh ok then would I do..
    Code (Text):

    return results.getInt("TOKENS");
  5. 4chan


    Click me
    Also click me.
    • Optimistic Optimistic x 1