mysql connector 3.5x_mysql-connector-java 6.x 使用(mysql 6.x驱动使用)

首先更新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的老配置和新的配置:

718e294ad50f33bbd4eecf9436b10a62.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值