首先更新mysql-connector-java的 jar 包,目前6.x 的最新版本是6.0.4:
mysql
mysql-connector-java
6.0.4
然后启动项目,发现出现异常:
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.
[WARNING] Unable to create initial connections of pool.
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.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:569)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:537)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:527)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:512)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:480)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:498)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:494)
看这句话:
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
是说mysql 的驱动类,位置改变了,修改配置文件:
把 driver_class=com.mysql.jdbc.Driver 修改为: driver_class=com.mysql.cj.jdbc.Driver
再看下面这句话:
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.
说在配置文件中没有配置时区,然后mysql 不知道采用何种时区:
我们修改配置:
把
jdbc_url=jdbc:mysql://127.0.0.1:3306/rx_shi?useUnicode=true&characterEncoding=utf8&useSSL=false
修改为
jdbc_url=jdbc:mysql:///rx_shi?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=false
然后重新启动项目,成功没有保存,增删改查验证通过。
下面贴出来我的 5.1.39的老配置和新的配置: