Solved MySQL Boolean value check if with else

Discussion in 'Plugin Development' started by ItsBlockFighter, Apr 28, 2018.

Thread Status:
Not open for further replies.
  1. Hi!

    I have a problem with it, let me ask the value, and if so much value is written, but if it does not write something else and it does not go. how can I not solve it?
    (Sorry my bad english)

    check code:
    Code:
    try {
                        core.getLogger().warning("x2552525);
    
                        ResultSet result = getStatement().executeQuery("SELECT Registered FROM `server` WHERE Registered = '1'");
    
                        while(result.next()) {
                            player.sendMessage("[1]");
                        } //else ? f the value is different here how to solve it?
    
                    } catch (Exception e) {
                        core.getLogger().warning("ERROR WHILST CREATING PLAYER PROFILE: ");
                        e.printStackTrace();
                    }
     
  2. I suppose you want to get all the rows plus columns from a resultset.
    If that is true then this code will help you out with extracting data from resultset.


    I hope to have helped you sufficiently and if there any questions, I will help you :)

    Code:
    Code:
      
        public List<List<Object>> getData(ResultSet result) throws Exception {
                List<List<Object>> rows = new ArrayList<>();
                ResultSetMetaData meta = result.getMetaData();
                List<Object> column;    
                while(result.next()) {
                    column = new ArrayList<>();
                    for(int place = 1; place <= meta.getColumnCount(); place++) {
                        column.add(result.getObject(place).toString().replace("''", "'"));
                    }
                    rows.add(column);
                }
                return rows;
            }
        }
     
Thread Status:
Not open for further replies.

Share This Page