mysql problem

Discussion in 'Plugin Development' started by dekrosik, Jun 12, 2015.

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

    dekrosik

    Hello how to make method to getPlayer in mysql
    example
    public Player getPlayerMysql(int position);
    and i give maybe 5, method return me what player is a 5 position
    my table:
    Code:
            query.append("CREATE TABLE IF NOT EXISTS `Ranking` (")
            .append("`id` INT(6) NOT NULL AUTO_INCREMENT, ")
            .append("`name` VARCHAR(16) NOT NULL UNIQUE, ")
            .append("`kills` INT(10), ")
            .append("`deaths` INT(10), ")
            .append("`points` INT(10), ")
            .append("`uuid` VARCHAR(255) UNIQUE, ")
            .append("PRIMARY KEY (`id`), ")
            .append("KEY (`name`, `uuid`))");
    
    im know how to get top 15 players
    Code:
            public void getTop(Player p) {
                try
                {
                    ResultSet rs = null;
                    PreparedStatement st = connection.prepareStatement("SELECT * FROM `Ranking` ORDER BY `points` DESC LIMIT 15");
                    int num = 1;
                    p.sendMessage(ChatColor.DARK_GRAY + "========== TOP 15 =======");
                    rs = st.executeQuery();
                    while (rs.next())
                    {
                    p.sendMessage( num + ". " + rs.getString(2) + ": " + rs.getString(5));   
                    num++;
                }
                p.sendMessage(ChatColor.DARK_GRAY + "=================");
                } catch (SQLException e) {
                    e.printStackTrace();
                }
        }
    
    ;/
     
  2. Offline

    RainoBoy97

    hint: SKIP & LIMIT
     
Thread Status:
Not open for further replies.

Share This Page