[Problem] When zone SpringBoot + mybatis query mysql datetime type data of the time difference 14 hours

[Problem] time zone MyBatis query MySQL's datetime data type time difference is 14 hours

Troubleshooting way

When the connection with the database, defined time zone, time zone to avoid mybatis frame acquired from mysql. On the plus connection serverTimezone = GMT% 2B8

spring.datasource.druid.asset.url=jdbc:mysql://loaclhost:3306/asset1?useUnicode=true&serverTimezone=GMT%2B8&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true

Here Insert Picture Description

Fault environment Introduction

project description
Database Type mysql
frame spring boot
Range of issues Because "CST" time zone negotiate a misunderstanding led to the time difference of 14 or 13 hours

Failure phenomenon and the error message

The results of a database query time than the time more than 14 hours.Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture Description

Failure analysis and resolution process

By looking at
the query mysql of mybatis datetime data type time difference of 14 hours
and to view
a JDBC because "CST" time zone in consultation with the MySQL misunderstanding led to the time difference of 14 or 13 hours of troubleshooting experience
and
with MySQL because District negotiated misunderstandings lead time "CST" worse 13 hours

to sum up

Encountered such a problem, or modify their procedure is relatively simple and crude, if the contact zone setting dba modify the general need to go process takes time.

life is beautiful,我是Alon,如果你有问题,欢迎给我留言。

Guess you like

Origin www.cnblogs.com/todayforever/p/11997424.html