Why am I getting this "Communication Communication Error Last Packet Sent ..." error when connecting to MySQL with Java (Netbeans)?

I am trying to use a MySQL database (which is installed on a virtual machine (Debian) on my computer and has an IP address 192.168.1.5) with Java using NetBeans.

I configured the connection as follows:

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

and then I get the following error:

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.)

My table mysql.userlooks like this (I know that it is % rootnot very safe, but this is just for simplification at the moment):

+------------+------------------+
| host       | user             |
+------------+------------------+
| %          | root             |
| 127.0.0.1  | root             |
| ::1        | root             |
| debVirtual |                  |
| localhost  |                  |
| localhost  | debian-sys-maint |
| localhost  | phpmyadmin       |
| localhost  | root             |
+------------+------------------+

What can I do to allow this connection?

+3
source share
4 answers

The problem was that the mysql configuration file on the server /etc/mysql/my.cnf

: bind-address IP- ,

bind-address = 192.168.1.5

bind-address = 127.0.0.1

.

+5

?

, , , . VM. VM (VirtualBox, VM ware...)

0

, . Lubuntu, my.cnf( ). /etc/mysql/mysql.conf.d/, : mysqld.cnf. , :

sudo su
***enter password***
cd /etc/mysql/mysql.conf.d
nano mysqld.cnf

then go to bind address 127.0.0.1 and change it to IPv4, which you can find in

ifconfig

Hope I helped.

0
source

The perfect solution:

  • Launch a wamp server before netbeans
  • Then open netbeans

It worked for me. When I close the wamp server, it shows me this error:

-1
source

All Articles