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.
Related
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.
I'm trying to connect to a MySQL database remotely, from a machine called pc.domain.com to a server called remotehost.domain.com
DriverManager.getConnection("jdbc:mysql://remotehost:3306", "user", "pass");
On the remote server I have the user 'user'#'pc.domain.com' (with appropriate permissions), but when I try to connect the following error occurs:
Host '128.0.200.82' is not allowed to connect to this MySQL server
I don't know if such validation is server or client side, although it makes more sense to be server sided. How can I force it to use the FQDN instead of the IP address to identify the connection?
Turned out to be a problem with the reverse lookup on my DNS.
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.
Hey guys i'm trying to connect mysql database from my friend's wifi. The database connects and works fine from all my other devices with are all on the same network but i want to connect to the database from an external network(my friends network).
I have replaced localhost/device ip with my public ip address which i got from whatsmyip.com
String connectionUrl = "jdbc:mysql://myPublicIp:3306/trial";
and i ran it from my friend's home:
this is what i got:
com.mysql.jdbc.CommunicationException: Communications link failure due to underlying exception:
BEGIN NESTED EXCEPTION
java.net.Connect.Exception
MESSAGE: Connection timed out: connect
As i said there is no prob with the code, it works fine for locally connected devices. I wanted to know if my string's syntax is wrong.
Assuming my public ip address is 50.50.50.50 and my device running mysql is 192.168.x.x and the port is 3306 how should i format my string.
Thanks.
You should forward your 3306 port for the device which got the database on it, otherwise your router can't decide which device to look for when you request connection through this port and it won't let anything through instead.
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.