In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to avoid the trap of the url time zone in mysql, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's learn about it!
1. No serverTimezone specified
Configure url in xml
The exception that occurs
Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value 'please thank you for your 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.
You must configure the server or JDBC driver (configure properties through serverTimezone), and if you want to use time zone support, you need to use a more detailed time zone value.
two。 Online solution
Add the parameter "serverTimezone=utc" after url
2.1. Problems encountered
Although there is nothing wrong with adding the time zone program above, we have a problem when inserting the time into the database with java code.
For example, the insertion time in the java code is: 2017-08-21 17:29:56
But the time shown in the database is: 2017-08-21 09:29:56
3. Root cause
Because of the time zone setting.
UTC represents global standard time, but the time we use is the Beijing time zone, or East eighth District, eight hours ahead of UTC.
UTC + (+ 0800) = local (Beijing) time
4. Solution
The time zone of url uses Chinese standard time. Also, just serverTimezone=Asia/Shanghai.
4.1 use java code to get local time zone id
Calendar cal = Calendar.getInstance (); TimeZone timeZone = cal.getTimeZone (); System.out.println (timeZone.getID ()); System.out.println (timeZone.getDisplayName ()); Asia/Shanghai above China Standard time is all the content about how to avoid the trap of url time zone in mysql. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.