title: Unable to connect MYSQL database from a Java programm in Ubuntu 16.04 (Communications link failure)
body: <p>My java program is working fine when I use localhot instead of IP address, but getting error when I connect using IP address. (I have to use IP address to connect, because it is a client server application).</p>
  
  <p>I have also changed this /etc/mysql/mysql.conf.d/mysqld.cnf file bind address from 127.0.0.1 to 0.0.0.0, But again I get the error message like -</p>
  
  <p><strong>com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 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.</strong></p>
  
  <p>My code is:-</p>
  
  <pre><code>try{
        Connection con;
        Statement st;
        Class.forName("com.mysql.jdbc.Driver");
        con=DriverManager.getConnection(
        "jdbc:mysql://172.16.16.185:3306/itcentre?
         verifyServerCertificate=false&amp;useSSL=true","root","");
  
      st=con.createStatement();
      ResultSet rs=st.executeQuery("select * from teacher");
      while(rs.next())
      {
          System.out.println(rs.getString(2));
      }
      rs.close();
      st.close();
      con.close();
   }
   catch(Exception e)
   {
      System.out.println(e);
   }
  </code></pre>