不灭的焱

革命尚未成功,同志仍须努力下载JDK17

作者:Albert.Wen  添加时间:2022-05-24 14:32:13  修改时间:2024-04-20 05:23:49  分类:数据采集/桌面自动化  编辑

报错:

Code:[MYSQLErrCode-02], Description:[数据库服务的IP地址或者Port错误,请检查填写的IP地址和Port或者联系DBA确认IP地址和Port是否正确。如果是同步中心用户请联系DBA确认idb上录入的IP和PORT信息和数据库的当前实际信息是一致的]. - 具体错误信息为:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received from the server was 3 milliseconds ago. The last packet sent successfully to the server was 2 milliseconds ago.

网友遇到的报错:

Thu Dec 20 12:50:09 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 

翻译:

不建议在没有服务器身份验证的情况下建立SSL连接,根据MySQL 5.5.45+、5.6.26+和5.7.6+的要求,如果没有设置显式选项,则必须默认建立SSL连接。为了符合不使用SSL的现有应用程序,verifyServerCertificate属性被设置为“false”。您需要通过设置useSSL=false显式禁用SSL,或者设置useSSL=true并为服务器证书验证提供信任存储。

经过翻译后是不是很清晰了,不建议在没有服务器身份验证的情况下建立SSL连接,只是不建议,如果你执意这么做的话呢,当然可以无视,那么如果你接受了人家的建议,该怎么解决这个问题呢?很简单,在你连接数据库的url后面加上参数即可,例如:

jdbc:mysql://localhost:3306/testdb?useSSL=false

使用上述标红的URL,即可解决该警告,标红参数前面为你数据库连接URL,如果有多个参数记得用&连接,例如:

jdbc:mysql://localhost:3306/testdb?characterEncoding=utf-8&useSSL=false

 

 

参考:https://blog.csdn.net/qq_41785135/article/details/85118329