I might encounter a bug when I connect to mysql with a domain name
Answered
- Host:ip ✅
- Host:***.***.com ✅
- Host:***.***.xyz ❌ But i use this host in other database connection tools is successful
Please sign in to leave a comment.
What is the host in question? Could it be resolved externally, or you have it configured through your hosts file, or local DNS server?
Konstantin Annikov
My host is aliyun.dingxs.xyz.I can ping it.
But in Datagrip or Idea
But use ip is ok.
There are a lot of network-related and java-related possible causes of the "communications link failure" error:
https://stackoverflow.com/a/10772407/8203759
Let's start from the following:
Add
into the idea.vmoptions file (Help | Edit custom VM options)
If it does not help, share the whole idea.log (Help | Collect Logs and Diagnostic Data)
Also, it could be DNS cache issue.
Try the following workaround:
The Java virtual machine (JVM) caches DNS name lookups. When the JVM resolves a hostname to an IP address, it caches the IP address for a specified period of time, known as the time-to-live (TTL).
To modify the JVM's TTL, set the networkaddress.cache.ttl property value for you data source settings advanced tab
-Dnetworkaddress.cache.ttl=60I cont upload a logs file,so copy some logs :
in the log can find those config,but still fail
Driver can't not establish connection via jdbc:mysql://aliyun.dingxs.xyz:13306, as workaround you cant use IP or another host name.