title: Communication failure with jdbc in java
body: <p>I'm trying to make a connection to a mysql database that we are hosting. We have installed phpmyadmin on it and we can easily access the database and it's content from there. (<a href="http://ipadress:port/phpmyadmin" rel="nofollow">http://ipadress:port/phpmyadmin</a>)</p>
  
  <p>The problem is that we keep getting communication failure. This is the piece of Java code I have:</p>
  
  <pre><code>public static void main(String[] args) {
      Connection conn;
      Statement st;
      ResultSet rs;
      try {
          Class.forName("com.mysql.jdbc.Driver");
          conn = DriverManager.getConnection("jdbc:mysql://ipadress/Database", "user", "password");
          st = conn.createStatement();
  
          String query = "SELECT * FROM adres";
          assert st != null;
          rs = st.executeQuery(query);
          System.out.println("Records from Database");
          while (rs.next()) {
              String straat = rs.getString("straat");
              String huisnummer = rs.getString("huisnummer");
              System.out.println("Straat: " + straat + "\nHuisnummer: " + huisnummer);
          }
      } catch (Exception ex) {
          System.out.println(ex.getMessage());
      }
  }
  </code></pre>
  
  <p>I've also tried adding it to the mysql workbench but I keep getting the same error, so I'm guessing it's not code-wise. What could be the reason behind this? Since I have no problem connecting to it with the phpmyadmin.</p>
  
  <p>Thanks!</p>
  
  <p>EDIT:
  The error message</p>
  
  <pre><code>Communications link failure
  The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
  </code></pre>