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"/>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了