Mysql版本过高的一些问题 和 时区问题

mysql服务使用的是

Server version: 8.0.27 MySQL Community Server - GPL

遇到的一些问题总结一下

 

1  驱动版本过低问题

mysql-connector-java-5.1.37-bin.jar  版本 会遇到  Could not create connection to database server.

 

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
### The error may exist in com/demo/dao/UserMapper.xml
### The error may involve com.demo.dao.UserMapper.findAll
### The error occurred while executing a query
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.

 

mysql-connector-java-5.1.37-bin.jar  以上版本驱动  druidDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");

mysql-connector-java-5.1.37-bin.jar  以上版本驱动  druidDataSource.setDriverClassName("com.mysql.jdbc.Driver");

 

 

 

2  时区问题

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
### The error may exist in com/demo/dao/UserMapper.xml
### The error may involve com.demo.dao.UserMapper.findAll
### The error occurred while executing a query
### Cause: java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

解决办法  : 

库名称后添加   ?serverTimezone=GMT%2B8
         %2B8表示时间移动到东八区  
<property name="url" value="jdbc:mysql://地址:端口号/库名称?serverTimezone=GMT%2B8"/>
posted @   __Ethan  阅读(311)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示