title: Sort in Java with data from a database
body: <p>I'm doing a game in java and I want to make a screen to fit the ten highest scores. I have a database and I think it is best to fill an array with the data of the items.</p>
  
  <p>This is the code of the class that connects to the database:</p>
  
  <pre><code>public Jugador[] buscarDiez() {
  
      Jugador[] diez = new Jugador[9];
      try {
          orden = conexion.createStatement();
          String sql = "SELECT user, score FROM player ORDER BY score LIMIT 9";
          rs = orden.executeQuery(sql);
  
          int i = 0;
  
          while (rs.next()) {
              diez[i].setUser(rs.getString("user"));
              diez[i].setScore(rs.getInt("score"));
  
              i = i + 1;
          }
      }
  }
  </code></pre>
  
  <p>What I can be doing wrong? </p>