Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internal Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure [duplicate]

I Have developed an application to capture data, retrieve information,delete and also update info. The application is developed in java swing and hibernate and uses MySQL version 5.5 as a database. I tested it on my local server or local host and its working fine. So now i took it a step further trying to access the database on the remote server. Please note that also the MySQL version i use on my local server is the same as the MySQL in the remote server.

I get the following error:

Internal Exception: 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.
Error Code: 0
like image 467
Raymomd Masuku Avatar asked Jan 30 '26 21:01

Raymomd Masuku


1 Answers

The problem is that your MySqlConnector/Driver can't establish a Connection to the remote server.

Check your jdbc URL and also the check if the wrong ports are used. Maybe the Mysql DB is not reachable from outside, than you can use a port forwarding with ssh, for example :

port forwarding:

ssh -L3306:127.0.0.1:3306 user@remoteServer 

than change your jdbc url to:

jdbc:mysql://localhost:3306/database

Explanation: -L port:host:hostport

Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.
...
Whenever a connection is made to this port, the connection is forwarded over the secure channel, and a connection is made to host port hostport from the remote machine.

Source: http://www.openbsd.org/cgi-bin/man.cgi?query=ssh&sektion=1

That means you request with your MySQL JDBC Driver(jdbc url) on the local 3306 port will be forwarded to the remote server on his local 3306 port, where the Mysql Database is listing.

like image 92
Zelldon Avatar answered Feb 01 '26 09:02

Zelldon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!