错误日志:


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.
 

连接mysql8时JDBC需要注意两个地方

  • 第一个:驱动类改成了 com.mysql.cj.jdbc.Driver

  • 第二个,驱动连接url后要拼接上 &serverTimezone= ,这个是时区设定,如果不设置时区在国内大概会与我们真正的时间相差13个小时,比如在java代码里面插入的时间为:2019-07-26 19:28:02,但是在数据库里面显示的时间却为:2019-07-26 06:28:02,而且国内的时区时间设定一般使用Asia/Shanghai,即是 serverTimezone=Asia/Shanghai (注意:没有北京时区:asia/beijing 这种设定)

解决上述错误就需要遵循第二个注意事项;


-END>