saysky / ForestBlog

一个简单漂亮的SSM(Spring+SpringMVC+Mybatis)博客系统
https://forestblog.liuyanzhao.com
4.52k stars 1.65k forks source link

MySql 数据库版本较高时候驱动版本太旧报错。 #22

Closed 1M15M3 closed 5 years ago

1M15M3 commented 5 years ago

MySql 版本: select version(); +-----------+ | version() | +-----------+ | 8.0.12 | +-----------+ 1 row in set (0.00 sec)

当前 8.0.12 MySql 环境下会报错:

2019-08-29 11:49:09,338 ERROR [com.alibaba.druid.pool.DruidDataSource] - init datasource error, url: jdbc:mysql://localhost:3306/forest_blog?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC java.sql.SQLException: Could not retrieve transation read-only status server

Caused by: java.sql.SQLException: Could not retrieve transation read-only status server

替换两个 Jar :

  1. spring-jdbc 屏蔽原来的:
        <!--<groupId>org.springframework</groupId>-->
        <!--<artifactId>spring-jdbc</artifactId>-->
        <!--<version>4.2.0.RELEASE</version>-->

添加新版本:

org.springframework spring-jdbc 5.1.9.RELEASE
  1. mysql-connector-java 屏蔽原来的:
        <!--<groupId>mysql</groupId>-->
        <!--<artifactId>mysql-connector-java</artifactId>-->
        <!--<version>5.1.30</version>-->

添加新版本:

mysql mysql-connector-java 8.0.17
saysky commented 5 years ago

建议使用 mysql5.x 如果使用 mysql8.x 需要修改驱动版本和驱动名