title: Error with sql and eclipse com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
body: <p>What have I done wrong?</p>
  
  <pre><code>import java.sql.*;
  public class DbConnect 
      private Connection con;
      private Statement st;
      private ResultSet rs;
  
  public DbConnect() throws SQLException{
      try{
      Class.forName("com.mysql.jdbc.Driver");
  
      String url = "jdbc:mysql://localhost:220/test";
      String user = "UserNameHere";
      String password = "PasswordHere";
      con = DriverManager.getConnection(url, user, password);
      st = con.createStatement();
      }catch(Exception e){
      System.out.println("ERROR: " + e);
      }
  }
  
  public void getData(){
     try{
      String query = "SELECT * FROM persons";
      rs = st.executeQuery(query);
      System.out.println("Records from database:");
  
      while(rs.next()){
  
          String name = rs.getString("name");
          String age = rs.getString("age");
  
          System.out.println("Name: " + name + "   Age: " + age);
      }
  
       }catch(Exception e){
          System.out.println("ERROR: " + e);
       }
     }
  }
  </code></pre>
  
  <p>I got this error:</p>
  
  <blockquote>
    <p>ERROR: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure</p>
  </blockquote>
  
  <p>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.</p>
  
  <blockquote>
    <p>ERROR: java.lang.NullPointerException</p>
  </blockquote>