MySQL5.7以上的版本需要配置ssl证书,并且MySQL5.7默认是开启SSL连接

我们先来看看出现的异常信息,如下。
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 2,594 milliseconds ago.  The last packet sent successfully to the server was 2,580 milliseconds ago.
### The error may exist in com/qijian/dao/UserMapper.xml
### The error may involve com.qijian.dao.UserDao.getUserList
### The error occurred while executing a query
### Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 2,594 milliseconds ago.  The last packet sent successfully to the server was 2,580 milliseconds ago.
 

原配置Mybatis-config.xml:
<property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=true&amp;useUnicode=true&amp;characterEncoding=UTF-8"
改:

 <property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8"/>

问题解决输出了结果:

但是还是不太明白:
    SSL(Secure Sockets Layer 安全套接层),及其继任者传输层安全(Transport Layer Security,TLS)是为网络通信提供安全及数据完整性的一种安全协议。TLS与SSL在传输层对网络连接进行加密。SSL为Netscape所研发,用以保障在Internet上数据传输的安全,利用数据加密(Encryption)的技术,可确保数据在网络上的传输过程中不会被截取及窃听。SSL协议位于TCP/IP协议与各种应用层协议之间,为数据通讯提供安全支持。

MySQL5.7以及MySQL5.7以上的版本需要配置ssl证书,并且MySQL5.7默认是开启SSL连接,如果强制用户使用SSL连接,那么应用程序的配置也需要明确指定SSL相关参数,否则程序会报错。因为之前用的是MySQL5.7以下的版本所以完全忽略了 。

posted @   韩立987  阅读(955)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示