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 @ 2022-03-09 06:15  __Ethan  阅读(295)  评论(0编辑  收藏  举报