Solved Problem checking rank in MySQL

Discussion in 'Plugin Development' started by WesJD, Nov 29, 2014.

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

    WesJD

    Hi,

    So, I've been creating a MySQL rank system for my network. Currently I'm stuck when checking the player's rank as it's returning null? I've put in some debug messages and it's checking the rank though not giving me a correct return value(null).

    Code:
    Code:java
    1. public static Rank getRank(Player p) {
    2. System.out.println("checking rank...");
    3. ResultSet res = null;
    4. try {
    5. res = Main.statement.executeQuery("SELECT rank FROM test WHERE uuid='" + p.getUniqueId() + "';");
    6. res.next();
    7. } catch (SQLException e) {
    8. e.printStackTrace();
    9. }
    10. try {
    11. if(res.getString("rank") == "DEFAULT") {
    12. System.out.println("GOT DEFAULT!");
    13. return DEFAULT;
    14. } // check other ranks with the same method


    Thanks in advance.
     
  2. WesJD
    I'm not familiar with MySQL so I don't know what the problem is, but you cannot compare Strings like that with ==. Use .equals() instead.
     
    Funergy likes this.
  3. Offline

    WesJD

    Assist
    That fixed it. Thanks. :)
     
Thread Status:
Not open for further replies.

Share This Page