title: JDBC Connection timed out
body: <p>Trying to create a JDBC based app that connects to a database allowing a user to edit a website.</p>
  
  <p>Each time I test the app from eclipse I get a connection timed out error and have no idea why.</p>
  
  <p>Sorry if it's a n00by question I'm new to JDBC. Any help or suggestions will be greatly appreciated.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>try 
  {
      Class.forName("com.mysql.jdbc.Driver").newInstance(); 
      Connection con = DriverManager.getConnection(
          "jdbc:mysql://nkuwebdata.db.8750359.hostedresource.com",
          username,
          password);
  
      Statement stmt = con.createStatement();
      ResultSet rs = stmt.executeQuery("Select * FROM tbl_adminLogin");
      while(rs.next())
      {
          String s = rs.getString("name");
          System.out.println(s);
          break;
      }
  } catch (SQLException e) 
  {
      // TODO Auto-generated catch block
      e.printStackTrace();
  } catch (InstantiationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  } catch (IllegalAccessException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  </code></pre>
  
  <p>Below is the Error Message that is printing out in my console:</p>
  
  <pre><code>com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 
  
  ** BEGIN NESTED EXCEPTION ** 
  
  java.net.ConnectException
  MESSAGE: Connection timed out: connect
  
  STACKTRACE:
  
  java.net.ConnectException: Connection timed out: connect
      at java.net.DualStackPlainSocketImpl.connect0(Native Method)
      at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
      at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
      at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
      at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
      at java.net.PlainSocketImpl.connect(Unknown Source)
      at java.net.SocksSocketImpl.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at java.net.Socket.&lt;init&gt;(Unknown Source)
      at java.net.Socket.&lt;init&gt;(Unknown Source)
      at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
      at com.mysql.jdbc.MysqlIO.&lt;init&gt;(MysqlIO.java:271)
      at com.mysql.jdbc.Connection.createNewIO(Connection.java:2771)
      at com.mysql.jdbc.Connection.&lt;init&gt;(Connection.java:1555)
      at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at uk.co.majorwebdesigns.ContentManager.connectToAndQueryDatabase(ContentManager.java:100)
      at uk.co.majorwebdesigns.ContentManager.createMenuBar(ContentManager.java:92)
      at uk.co.majorwebdesigns.ContentManager.launch(ContentManager.java:61)
      at uk.co.majorwebdesigns.ContentManager.main(ContentManager.java:133)
  
  
  ** END NESTED EXCEPTION **
  
  
  
  Last packet sent to the server was 2 ms ago.
      at com.mysql.jdbc.Connection.createNewIO(Connection.java:2847)
      at com.mysql.jdbc.Connection.&lt;init&gt;(Connection.java:1555)
      at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at uk.co.majorwebdesigns.ContentManager.connectToAndQueryDatabase(ContentManager.java:100)
      at uk.co.majorwebdesigns.ContentManager.createMenuBar(ContentManager.java:92)
      at uk.co.majorwebdesigns.ContentManager.launch(ContentManager.java:61)
      at uk.co.majorwebdesigns.ContentManager.main(ContentManager.java:133)
  </code></pre>