JDBC Connection mysq servertimezone settings

Source: Internet
Author: User
Tags time zones

MySQL always returns a problem, 8 hours earlier than the actual time. Check that there is a problem with the time zone configured in the URL of the JDBC connection, first

jdbc:mysql://172.xx.xx.xx:3306/test?useunicode=true&characterencoding=gbk&usessl=true& Usejdbccomplianttimezoneshift=true&uselegacydatetimecode=false&servertimezone=utc

The possible parameters, such as GMT, GMT8, utc+8,utc0800, and so on, were all error. Later in the MySQL document found that the available time zones are in the/usr/share/zoneinfo directory, ll find the available time zone information below

lewis@lewis-dzwww:/usr/share/zoneinfo$ ll total dosage 308 drwxr-xr-x root root 4096 May 12:54./drwxr-xr-x 334 root root 12288 June 21 15:11. /drwxr-xr-x 2 root 4096 May 12:56 africa/drwxr-xr-x 6 root root 4096 May 12:56 america/drwxr-xr-x 2 Root root 4096 May 12:56 antarctica/drwxr-xr-x 2 root 4096 May 12:56 arctic/drwxr-xr-x 2 root root 409 6 May 12:56 asia/drwxr-xr-x 2 root root 4096 May 12:56 atlantic/drwxr-xr-x 2 root root 4096 May 12:56 Aus    Tralia/drwxr-xr-x 2 root 4096 May 12:56 brazil/drwxr-xr-x 2 root root 4096 May 12:56 canada/-rw-r--r--   1 root 2102 April 02:09 CET drwxr-xr-x 2 root root 4096 May 12:56 chile/-rw-r--r--1 root root 2294 April 02:09 cst6cdt-rw-r--r--1 root 2437 April 02:09 cuba-rw-r--r--1 root root 1876 April 02:09 eet-rw-r- -r--1 root 1972 April 02:09 egypt-rw-r--r--1 root root 3559 April 02:09 eire-rw-r--r--1 root root 12 7 4Monthly 02:09 est-rw-r--r--1 root 2294 April 02:09 Est5edt drwxr-xr-x 2 root root 4096 May 12:56 etc/drwxr -xr-x 2 root 4096 May 12:56 europe/-rw-r--r--1 root root 264 April 02:09 factory-rw-r--r--1 root Roo  T 3687 April 02:09 GB lrwxrwxrwx 1 root 2 May 09:07 gb-eire-> gb-rw-r--r--1 root root 127 April 21 02:09 GMT lrwxrwxrwx 1 root root 3 May 09:07 GMT0-> GMT lrwxrwxrwx 1 root root 3 May 09:07 GMT-0-& Gt GMT lrwxrwxrwx 1 root 3 May 09:07 gmt+0-> GMT lrwxrwxrwx 1 root root 3 May 09:07 Greenwich ; gmt-rw-r--r--1 root 1189 April 02:09 hongkong-rw-r--r--1 root root 128 April 02:09 hst-rw-r--r--1 ro  OT root 1190 April 02:09 Iceland drwxr-xr-x 2 root root 4096 May 12:56 indian/-rw-r--r--1 root root 1678 April 02:09 iran-rw-r--r--1 root 4475 February 17:01 iso3166.tab-rw-r--r--1 root root 2265 April 02:09 Israel- rw-r--r--1 root Root 507 April 02:09 jamaica-rw-r--r--1 root root 355 April 02:09 japan-rw-r--r--1 root root 237 April 21 0 2:09 kwajalein-rw-r--r--1 root 10384 February 23:58 leap-seconds.list-rw-r--r--1 root root 655 April 02:09 L Ibya lrwxrwxrwx 1 root 14 May 09:07 localtime->/etc/localtime-rw-r--r--1 root 2102 April 21 02:0 9 MET drwxr-xr-x 2 root root 4096 May 12:56 mexico/-rw-r--r--1 root root 127 April 02:09 mst-rw-r--r--1 R  Oot root 2294 April 02:09 mst7mdt-rw-r--r--1 root 2453 April 02:09 navajo-rw-r--r--1 root root 2460 April 02:09 nz-rw-r--r--1 root 2057 April 02:09 nz-chat drwxr-xr-x 2 root root 4096 May 12:56 pacific/-rw-r --r--1 root 2705 April 02:09 poland-rw-r--r--1 root root 3453 April 02:09 Portugal drwxr-xr-x Root Roo T 4096 May 12:56 posix/-rw-r--r--1 root 3545 April 02:09 posixrules-rw-r--r--1 root root 414 April 21 0 2:09 prc-rw-r--r--1Root root 2294 April 02:09 pst8pdt drwxr-xr-x root root 4096 May 12:56 right/-rw-r--r--1 root root 800 April 02:09 roc-rw-r--r--1 root 571 April 02:09 rok-rw-r--r--1 root 428 April 02:09 Singapore drwxr-    Xr-x 2 root 4096 May 12:56 systemv/-rw-r--r--1 root root 2747 April 02:09 turkey-rw-r--r--1 root root   127 April 02:09 UCT lrwxrwxrwx 1 root 4 May 09:07 Universal-> Zulu drwxr-xr-x 2 root root 4096 May
12:56 us/lrwxrwxrwx 1 root 4 May 09:07 UTC-> zulu-rw-r--r--1 root root 1873 April 02:09 WET -rw-r--r--1 root 1528 April 02:09 w-su-rw-r--r--1 root root 17533 April 16:01 zone1970.tab-rw-r--r--1 R Oot root 19014 April 16:01 zone.tab-rw-r--r--1 root root 127 April 02:09 Zulu

To resolve this issue, you can select Hongkong, Asia/shanghai, or Asia/hongkong as parameters in the East 8 area, and the modified URL is

jdbc:mysql://172.xx.xx.xx:3306/test?useunicode=true&characterencoding=gbk&usessl=true& Usejdbccomplianttimezoneshift=true&uselegacydatetimecode=false&servertimezone=hongkong

Time to return is no problem.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.