title: Why I get this error 'Communications link failure The last packet sent...' when connecting to MySQL with Java (Netbeans)?
body: <p>I am trying to use MySQL database (that is installed on virtual machine (Debian) on my pc and has IP address <code>192.168.1.5</code> ) from Java with use of NetBeans. </p>
  
  <p>I have configured the connection as follows : </p>
  
  <pre><code>Driver Name MySQL(Connector/J Driver)
  
  Host 192.168.1.5
  
  Database test
  
  Username root
  
  Password *
  
  JDBC URL jdbc:mysql://192.168.1.5:3306/test
  </code></pre>
  
  <p>and then I get the following error : </p>
  
  <pre><code>cannot establish a connection to jdbc:mysql://192.168.1.5:3306/test using 
    com.mysql.jdbc.Driver (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>
  
  <p>My <code>mysql.user</code> table looks like this ( I know <code>% root</code> is not very secure but this is just to simplify things for the moment): </p>
  
  <pre><code>+------------+------------------+
  | host       | user             |
  +------------+------------------+
  | %          | root             |
  | 127.0.0.1  | root             |
  | ::1        | root             |
  | debVirtual |                  |
  | localhost  |                  |
  | localhost  | debian-sys-maint |
  | localhost  | phpmyadmin       |
  | localhost  | root             |
  +------------+------------------+
  </code></pre>
  
  <p>What can I do to allow this connection ? </p>