Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
- Error updating database. Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
- The error may exist in mapper/UserMapper.xml
- The error may involve User.insert
- The error occurred while executing an update
- Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure)
Error updating database. Cause: com.mysql.cj.jdbc.exceptions.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.
The error may exist in mapper/UserMapper.xml
The error may involve User.insert
The error occurred while executing an update
Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure)
原因之一可能是端口号错误,如笔者在url上写错成3206号端口
<dataSource type = "UNPOOLED">
<property name = "driver" value = "com.mysql.cj.jdbc.Driver"/>
<property name = "url" value = "jdbc:mysql://127.0.0.1:3206/qikegu_mybatis?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8"/>
<property name = "username" value = "root"/>
<property name = "password" value = "123456"/>
</dataSource>
改成3306端口号(大概率是这个,也有可能你设置的不同)
<dataSource type = "UNPOOLED">
<property name = "driver" value = "com.mysql.cj.jdbc.Driver"/>
<property name = "url" value = "jdbc:mysql://127.0.0.1:3306/qikegu_mybatis?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8"/>
<property name = "username" value = "root"/>
<property name = "password" value = "123456"/>
</dataSource>
除了乱码,还算成功