数据库连接 The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone.

数据库连接错误提示如下:

警告: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1fdce27 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (2). Last acquisition attempt exception: 
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.driver = com.mysql.jdbc.Driver
jdbc.url = jdbc:mysql://localhost:3306/seckill
jdbc.username = root
jdbc.password = root

pom.xml

<dependency>
       <groupId>mysql</groupId>
       <artifactId>mysql-connector-java</artifactId>
       <version>6.0.5</version>
</dependency>

分析原因:
mysql 高版本里的时间区所导致的错误
解决办法
方法一:
使用低版本的mysql

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.39</version>
 </dependency>

方法二:
在 jdbc.url 后面加入 serverTimezone=UTC ,用了CTT中国台湾时区避免产生8小时时差

jdbc.url = jdbc:mysql://localhost:3306/seckill?serverTimezone=UTC

方法三:
修改本地 mysql 里的时间配置, mysql 里默认是 SYSTEM。

set global time_zone='+8:00'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值