JDBC 连接报错

2018/10/25 posted in  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.
...

解决办法

https://segmentfault.com/q/1010000008813924

; eclipse.ini
-Djava.net.preferIPv4Stack=true

具体错误原因嘛,好像是由于jvm中的配置改变,导致jvm无法通过网络获取部分信息

自述)确实,刚刚升级 JDK 到 Java 11,然后由切换回 Java 8。

# ~/src/bash/bash_profile.d/lang.sh
...
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
#export JAVA_HOME=$(/usr/libexec/java_home -v 11)
...