title: Optimize speed between application and dbhost
body: <p>How to optimize the speed between a JAVA application (written in Netbeans) and my MYSQL Database (hosted at an external DB provider)?</p>
  
  <p>Let's say I have the following code;</p>
  
  <pre><code>private void fillPlayersList()
  {
      try
      {
          PlayerListModel.clear();
          Connection userConn = SimpleDataSource.getConnection();
          Statement userStat = userConn.createStatement();
          String userquery = "SELECT * FROM player";
          ResultSet userResult = userStat.executeQuery(userquery);
          if(userResult.next())
          {
              PlayerList.setEnabled(true);
              userResult.previous();
              while (userResult.next()) {
                  int id = userResult.getInt("player_id");
                  String username = userResult.getString("username");
                  String ip = userResult.getString("ip");
                  PlayerListModel.addElement(new PlayerItem(id, username, ip));
              }
          }
          userConn.close();
          PlayerList.setModel(PlayerListModel);
      }
      catch(SQLException e)
      {
          System.out.println(e);
      }
  
  } 
  </code></pre>
  
  <p>It takes aaaggeeesss before this has been completed! How can I optimize a code like this?</p>
  
  <p>Thanks!</p>