I have made a program that connects with a remote database. I used a database on my web hosting as the database. Within previous months it works fine. But since yesterday, it shows errors:
Java:-
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.
so I just try to check the connection on python, but it also gave me an error:
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Also, I tried connecting to another remote database from the same code, It connects without any error. So what should I do next? plz help
Use DBveaver (enter link description here) client to connect to your database.
Test the connectivity then try to connect using code. This will help you to debug the issue easier.
Related
I have a java project and for that, I needed a remote database, I purchased a aws instance for public IP, installed MySql with PhpMyAdmin but the database is not connecting with the project via my public IP but if I use a ngrok port forward then it is connecting with the database, and the error its producting is:
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.
please help!!
Working with Ngrok
Not working with public ip
Ensure that the database has a public endpoint (ping it for instance in order to see that it has a public address). Then just check security group permissions.
I'm having a problem connecting to my database remotely. I'm trying to interact with my database via a java program and the connection doesn't work. I also tried to connect via "LibreOffice Base" and it doesn't work either. I'll give you my manipulations:
Step 1: I create a DB
Step 2: I enable remote access
Step 3: I set my Java App
And when run I get this error:
com.mysql.cj.jdbc.exceptions.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.
I contacted the support and they told me that the error came from my site and that I had to modify the default.php file (I don't have a website for the moment), they told me that they didn't know anything about development and directed me to you.
Thank you in advance for your help.
I finally solved the problem on my own. All I had to do was disable NordVPN.
I don't know if it's because I'm using particular DNS (cloudfare) or if it's using a VPN but the problem is fixed.
Sincerely
I'm trying to open a connection from my NetBeans IDE to my remote MySQL database. I've put in what I think is the correct parameters in the response fields but when I try to test the connection it gives me this error message:
Cannot establish a connection to
jdbc:mysql://198.136.54.104:3306/myedigit_FirstDb?zeroDateTimeBehavior=convertToNull
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.
Please let me know if you need any more information I'll be happy to provide it.
Your host may not allowing remote connection.
You may need to add Access Host by Login into your host server and go to Remote MySql (I am referring GoDaddy)
You need to provide either your IP Address in host or % to access remotely from anywhere.
I have a Java (Swing) desktop connected to a godaddy MySQL database (online database). Till the time database was offline, this was not at all the problem, but now I get this exception when I try to access some menu which involves a database access.
Also, I create a static connection object when my application start, and never close it when the application is running.
This is the description of Exception, please help if you can. Thanks :)
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link fai
lure
Last packet sent to the server was 47 ms ago.
SOME MORE STACK TRACE AND THEN THE CHAINED CAUSE
Caused by: java.io.EOFException: Can not read response from server. Expected to
read 4 bytes, read 0 bytes before connection was unexpectedly lost.
I am assuming that you are on a shared hosting. Connecting to such a hosting publicly is not advisable.
Dealing with the problem this seems a problem with Remote SQL. There are a few things you can do
1. Go to your cPanel or equivalent and navigate to Remote SQL add the address 0.0.0.0 which will allow connections from any public ip that may want to connect with it. If your are using a vpn like AWS you have to manually edit the my.cnf or my.ini depending on weather you are hosted on linux or windows, add
bind-address = 0.0.0.0
under the
[mysqld]
tag
Next you need to create a user which can be accessed from any ip as root user only has permission to be accessed locally
GRANT ALL ON yourdatabasename.* TO user#'%' IDENTIFIED BY 'yourRootPassword';
I am trying to connect to my android device with my mysql database, I can do it in local (from a emulation device) but when I use my IP to connect to with my mobile I get:
Communication Link failure
The last packet send succesfully to the server was 0 millisecond ago. The driver has not recived any packet from the server
my code is:
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://MYIP:3306/BD", "USER", "USER");
with localhost it works:
Connection conn=DriverManager.getConnection("jdbc:mysql://10.0.2.2:3306/BD", "USER", "USER");
Thanks for your help.
To connect your Android device to Mysql you should use webs ervices. you can find more information in this tutorial
the Tutorial use PHP to creat web services, however you can use any other server side language to connect with mysql database, this will return JSON data that you can parse it to in your android app
It seems this is a network issue, if the devices are in the same LAN don't use your internet IP. Or even if the devices are in different network your router could be blocking your connection.