- 操作系统
- 未知
- 开发语言
- 开源协议
- 未知
-
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' prope
2019-10-09 10:17:27目录 错误界面 解决方案 第一,设置mysql时区。 第二,同步mysql驱动。 前进的道路充满荆棘。...进入“高级”选项卡,手动设置“serverTimezone”属性。 看起来是时区出了问题。时区怎么会出问题?坑真多。网...目录
前进的道路充满荆棘。
错误界面
IDEA连接mysql,地址,用户名,密码,数据库名,全都配置好了,点测试连接,咔!不成功!
界面是这样的,
翻译过来就是:服务器返回无效时区。进入“高级”选项卡,手动设置“serverTimezone”属性。
看起来是时区出了问题。时区怎么会出问题?坑真多。网上搜了各种解决办法,琳琅满目,复杂的简单的,总算是解决了!
解决方案
我的问题出在两块,第一,设置mysql的时区。第二,mysql驱动的版本。详细步骤如下:
第一,设置mysql时区。
1,我们先来检查下mysql时区。
( 这里有个小插曲~~~~~~~你的mysql,配置好环境变量了吗 )
配置完环境变量,就可以在命令窗口直接执行下面的命令啦!
进入命令窗口(Win + R),连接数据库 mysql -hlocalhost -uroot -p,回车,输入密码,回车,如图:
2,继续输入 show variables like'%time_zone'; (注意不要漏掉后面的分号),回车,如图:
显示 SYSTEM 就是没有设置时区啦。
3,现在我们来设置时区。
输入set global time_zone = '+8:00'; 注意不要漏掉后面的分号),回车,如图:
这便是设置成功啦!
这时你重新连接下数据库,也许能连接成功!如果没有,就继续往下走!
第二,同步mysql驱动。
我本机安装的mysql版本是5.7的,那么IDEA要连接mysql也应该匹配下驱动版本。把Driver改成MySQL for 5.1就可以了
在点击Test Connection测试下,成功啦!
【补充】
如果,你选的是MySQL,
数据库又是其他版本的,也没关系。
在驱动列表里找到 MySQL ,右边Driver files 里,选择一下你需要的版本,保存就可以了。
-
timezone
2017-09-09 16:07:30TimeZone timeZone = TimeZone.getTimeZone("Asia/Hong_Kong"); //设置时区 Calendar calendar = Calendar.getInstance(Locale.getDefault()); calendar.setTimeZone(timeZone); calendar.set时区转换
TimeZone timeZone = TimeZone.getTimeZone("Asia/Hong_Kong"); //设置时区
Calendar calendar = Calendar.getInstance(Locale.getDefault());
calendar.setTimeZone(timeZone);
calendar.setTimeInMillis(Long.valueOf(time)); //0时间(毫秒)
int zoneOffset = calendar.get(Calendar.ZONE_OFFSET); //偏移量
int dstOffset = calendar.get(Calendar.DST_OFFSET); //偏移量
calendar.add(Calendar.MILLISECOND, +(zoneOffset + dstOffset));
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(df.format(calendar.getTime())); -
time zone
2020-07-02 10:58:58mysql global time zone = UTC 前端调用java程序入参如下: { "dateTime":"2020-07-01 9:07:04", "timeStamp":"2020-07-01 9:07:04" } url: jdbc:mysql://122.51.245.236:3306/z?useSSL=false&useUnicode=...mysql global time zone = UTC
前端调用java程序入参如下:
{ "dateTime":"2020-07-01 9:07:04", "timeStamp":"2020-07-01 9:07:04" }
url: jdbc:mysql://122.51.245.236:3306/z?useSSL=false&useUnicode=true&characterEncoding=utf-8&useLegacyDatetimeCode=false&serverTimezone=UTC
会话以UTC时区,查看 新插入数据如下
url: jdbc:mysql://122.51.245.236:3306/z?useSSL=false&useUnicode=true&characterEncoding=utf-8&useLegacyDatetimeCode=false&serverTimezone=Asia/Tokyo
会话以UTC时区,查看 新插入数据如
url: jdbc:mysql://122.51.245.236:3306/z?useSSL=false&useUnicode=true&characterEncoding=utf-8&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
会话以UTC时区,查看 新插入数据如
会话以Asia/Shanghai时区,查看 新插入数据如
set time_zone = '+8:00'; show variables like '%time_zone%' select * from _time;
datetime 与timestamp区别:- datetime类型,java传入的是什么时间数据库存的就是什么时间,和时区没有关系
- timestamp类型,和时区有关系。简单理解:这个值是用两个字段共同标识出来的
- mysql default timezone + date
- java存取数据时,返回给java的date值是在默认时区下对应的date值
- time_stamp 只支持到2038年,这个有很大的局限性
serverTimezone可选值列举:
<?xml version="1.0" encoding="UTF-8"?> <timezones> <timezone id="Asia/Shanghai">中国标准时间 (北京)</timezone> <timezone id="Asia/Hong_Kong">香港时间 (香港)</timezone> <timezone id="Asia/Taipei">台北时间 (台北)</timezone> <timezone id="Asia/Seoul">首尔</timezone> <timezone id="Asia/Tokyo">日本时间 (东京)</timezone> <timezone id="America/New_York">美国东部时间 (纽约)</timezone> <timezone id="America/Denver">美国山区时间 (丹佛)</timezone> <timezone id="America/Costa_Rica">美国中部时间 (哥斯达黎加)</timezone> <timezone id="America/Chicago">美国中部时间 (芝加哥)</timezone> <timezone id="America/Mexico_City">美国中部时间 (墨西哥城)</timezone> <timezone id="America/Regina">美国中部时间 (里贾纳)</timezone> <timezone id="America/Los_Angeles">美国太平洋时间 (洛杉矶)</timezone> <timezone id="Pacific/Majuro">马朱罗</timezone> <timezone id="Pacific/Midway">中途岛</timezone> <timezone id="Pacific/Honolulu">檀香山</timezone> <timezone id="America/Anchorage">安克雷奇</timezone> <timezone id="America/Tijuana">美国太平洋时间 (提华纳)</timezone> <timezone id="America/Phoenix">美国山区时间 (凤凰城)</timezone> <timezone id="America/Chihuahua">奇瓦瓦</timezone> <timezone id="America/Bogota">哥伦比亚时间 (波哥大)</timezone> <timezone id="America/Caracas">委内瑞拉时间 (加拉加斯)</timezone> <timezone id="America/Barbados">大西洋时间 (巴巴多斯)</timezone> <timezone id="America/Manaus">亚马逊标准时间 (马瑙斯)</timezone> <timezone id="America/St_Johns">纽芬兰时间 (圣约翰)</timezone> <timezone id="America/Santiago">圣地亚哥</timezone> <timezone id="America/Argentina/Buenos_Aires">布宜诺斯艾利斯</timezone> <timezone id="America/Godthab">戈特霍布</timezone> <timezone id="America/Montevideo">乌拉圭时间 (蒙得维的亚)</timezone> <timezone id="America/Sao_Paulo">圣保罗</timezone> <timezone id="Atlantic/South_Georgia">南乔治亚</timezone> <timezone id="Atlantic/Azores">亚述尔群岛</timezone> <timezone id="Atlantic/Cape_Verde">佛得角</timezone> <timezone id="Africa/Casablanca">卡萨布兰卡</timezone> <timezone id="Europe/London">格林尼治标准时间 (伦敦)</timezone> <timezone id="Europe/Amsterdam">中欧标准时间 (阿姆斯特丹)</timezone> <timezone id="Europe/Belgrade">中欧标准时间 (贝尔格莱德)</timezone> <timezone id="Europe/Brussels">中欧标准时间 (布鲁塞尔)</timezone> <timezone id="Europe/Sarajevo">中欧标准时间 (萨拉热窝)</timezone> <timezone id="Africa/Brazzaville">西部非洲标准时间 (布拉扎维)</timezone> <timezone id="Africa/Windhoek">温得和克</timezone> <timezone id="Asia/Amman">东欧标准时间 (安曼)</timezone> <timezone id="Europe/Athens">东欧标准时间 (雅典)</timezone> <timezone id="Asia/Beirut">东欧标准时间 (贝鲁特)</timezone> <timezone id="Africa/Cairo">东欧标准时间 (开罗)</timezone> <timezone id="Europe/Helsinki">东欧标准时间 (赫尔辛基)</timezone> <timezone id="Asia/Jerusalem">以色列时间 (耶路撒冷)</timezone> <timezone id="Africa/Harare">中部非洲标准时间 (哈拉雷)</timezone> <timezone id="Europe/Minsk">明斯克</timezone> <timezone id="Asia/Baghdad">巴格达</timezone> <timezone id="Europe/Moscow">莫斯科</timezone> <timezone id="Asia/Kuwait">科威特</timezone> <timezone id="Africa/Nairobi">东部非洲标准时间 (内罗毕)</timezone> <timezone id="Asia/Tehran">伊朗标准时间 (德黑兰)</timezone> <timezone id="Asia/Baku">巴库</timezone> <timezone id="Asia/Tbilisi">第比利斯</timezone> <timezone id="Asia/Yerevan">埃里温</timezone> <timezone id="Asia/Dubai">迪拜</timezone> <timezone id="Asia/Kabul">阿富汗时间 (喀布尔)</timezone> <timezone id="Asia/Karachi">卡拉奇</timezone> <timezone id="Asia/Oral">乌拉尔</timezone> <timezone id="Asia/Yekaterinburg">叶卡捷林堡</timezone> <timezone id="Asia/Calcutta">加尔各答</timezone> <timezone id="Asia/Colombo">科伦坡</timezone> <timezone id="Asia/Katmandu">尼泊尔时间 (加德满都)</timezone> <timezone id="Asia/Almaty">阿拉木图</timezone> <timezone id="Asia/Rangoon">缅甸时间 (仰光)</timezone> <timezone id="Asia/Krasnoyarsk">克拉斯诺亚尔斯克</timezone> <timezone id="Asia/Bangkok">曼谷</timezone> <timezone id="Asia/Irkutsk">伊尔库茨克时间 (伊尔库茨克)</timezone> <timezone id="Asia/Kuala_Lumpur">吉隆坡</timezone> <timezone id="Australia/Perth">佩思</timezone> <timezone id="Asia/Yakutsk">雅库茨克时间 (雅库茨克)</timezone> <timezone id="Australia/Darwin">达尔文</timezone> <timezone id="Australia/Brisbane">布里斯班</timezone> <timezone id="Asia/Vladivostok">海参崴时间 (符拉迪沃斯托克)</timezone> <timezone id="Pacific/Guam">关岛</timezone> <timezone id="Australia/Adelaide">阿德莱德</timezone> <timezone id="Australia/Hobart">霍巴特</timezone> <timezone id="Australia/Sydney">悉尼</timezone> <timezone id="Asia/Magadan">马加丹时间 (马加丹)</timezone> <timezone id="Pacific/Auckland">奥克兰</timezone> <timezone id="Pacific/Fiji">斐济</timezone> <timezone id="Pacific/Tongatapu">东加塔布</timezone> </timezones>
如果想看上面城市具体对应的时区可以调用下面的方法
/** * 获取城市所在时区 * @param targetId 目标时区id 比如:America/New_York * @return string 时区 比如:+08:00 */ public static String getTimeZone(String targetId){ //校验入参是否合法 if (null == targetId || "".equals(targetId)){ return null; } try { TimeZone timeZone = TimeZone.getTimeZone(targetId); SimpleDateFormat outputFormat = new SimpleDateFormat("Z"); outputFormat.setTimeZone(timeZone); Date date = new Date(System.currentTimeMillis()); //加上冒号显示,把+0800转成+08:00 StringBuffer stringBuffer = new StringBuffer(outputFormat.format(date)); return stringBuffer.insert(3, ":").toString(); } catch (Exception e) { e.printStackTrace(); return null; } }
-
Time Zone
2015-04-16 23:27:27转载于:http://lua-users.org/wiki/TimeZone...The following function portably returns a timezone string in the form +hhmm or -hhmm. One cannot use os.date("%z") as the format of its return value is non-p转载于:http://lua-users.org/wiki/TimeZone
The following function portably returns a timezone string in the form
+hhmm
or-hhmm
. One cannot useos.date("%z")
as the format of its return value is non-portable; in particular, Windows systems don't use the C99 semantics forstrftime()
. The following code should portably produce a timezone string for the current local time.NOTE: the following only computes the timezone offset for "now", which differs from
os.date("%z")
which can handle times in the past or future, taking daylight savings time into account. Alternatively, you can use get_timezone_anystamp(ts) below-
-- Compute the difference in seconds between local time and UTC. local function get_timezone() local now = os.time() return os.difftime(now, os.time(os.date("!*t", now))) end timezone = get_timezone() -- Return a timezone string in ISO 8601:2000 standard form (+hhmm or -hhmm) local function get_tzoffset(timezone) local h, m = math.modf(timezone / 3600) return string.format("%+.4d", 100 * h + 60 * m) end tzoffset = get_tzoffset(timezone) --[[ debugging for _, tz in ipairs(arg) do if tz == '-' then tz = timezone else tz = 0 + tz end print(tz, get_tzoffset(tz)) end --]] -- return the timezone offset in seconds, as it was on the time given by ts -- Eric Feliksik local function get_timezone_offset(ts) local utcdate = os.date("!*t", ts) local localdate = os.date("*t", ts) localdate.isdst = false -- this is the trick return os.difftime(os.time(localdate), os.time(utcdate)) end
-
TimeZone
2011-10-19 15:04:19TimeZone Convert: //要计算的区时=已知区时-(已知区时的时区-要计算区时的时区),(注:东时区为正,西时区为负) //当算出的区时为负数时,应加上24:00,日期减一天 //当算出的区时大于或等于24:00时,应减去24... -
com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的区别 serverTimezone设定
2017-12-06 17:09:14com.mysql.jdbc.Driver 是 mysql-connector-java 5中的, com.mysql.cj.jdbc.Driver 是 mysql-connector-java 6中的1,JDBC连接Mysql5 ...url=jdbc:mysql://localho -
The server time zone value xxxxxxx is unrecognized or represents more than one time zone.
2020-06-05 11:47:58环境 SpringBoot mybatis 问题 项目启动时报错 java.sql.SQLException: The server time zone value... You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to -
mysql serverTimezone
2018-05-04 22:45:49serverTimezone=UTCservertime=UTC导致时间差8个小时(MySQL jdbc 6.0 版本以上必须配置此参数)虽然上面加上时区程序不出错了,但是我们在用java代码插入到数据库时间的时候却出现了问题。比如在java代码里面插入的... -
java timezone_Java TimeZone getTimeZone()方法与示例
2020-07-12 23:28:06java timezone TimeZone类的getTimeZone()方法 (TimeZone Class getTimeZone() method) getTimeZone() method is available in java.util package. getTimeZone()方法在java.util包中可用。 getTimeZone() method is... -
serverTimezone
2020-04-07 22:58:43The server time zone value '�й���ʱ��' is unrecognized or represents more than ... You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to u... -
java timezone_Java TimeZone getDefault()方法与示例
2020-07-14 07:56:53java timezone TimeZone类的getDefault()方法 (TimeZone Class getDefault() method) getDefault() method is available in java.util package. getDefault()方法在java.util包中可用。 getDefault() method is used... -
idea连接mysql报错Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' ...
2019-09-09 14:09:32原因:服务器返回无效时区,转到“高级”选项卡并手动设置“serverTimezone”属性。 在mysql的命令行窗口输入以下命令即可: show variables like ‘%time_zone%’; set global time_zone=’+8:00’; ... -
TIMESTAMP WITH TIME ZONE &TIMESTAMP WITH LOCAL TIME ZONE
2014-10-31 09:16:391、创建表 CREATE TABLE TIMESTAMP_TEST( ...TIMESTP_TZ TIMESTAMP WITH TIME ZONE, --当前会话 TIMESTP_LTZ TIMESTAMP WITH LOCAL TIME ZONE) --数据库 2、添加数据 INSERT INTO TIMESTAMP_TEST -
JDBC报错:The server time zone value is unrecognized or represents more than one time zone 已解决
2020-11-03 22:32:32一、详细报错信息 Caused by: java.sql.SQLException: The server time ... You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zo -
android timezone 时区
2019-09-17 05:48:48android timezone 时区: <timezone id="Pacific/Majuro">马朱罗</timezone><timezone id="Pacific/Midway">中途岛</timezone><timezo... -
url错误:Server returns invalid timezone.Need to set ‘serverTimezone‘ property.
2020-09-06 14:51:25出现错误:Server returns invalid timezone.Need to set ‘serverTimezone’ property. 加上:?serverTimezone=GMT%2B8 然后 然后最重要的一点: url照常写就可以了。 -
Java.util.TimeZone中TimeZone的用法
2019-02-12 17:12:47java.util.TimeZone 类型:abstract class 继承:java.lang.Object 实现的接口:Serializable、Cloneable 意味着该类的实例可以被序列化和按字段复制 直接已知子类:SimpleTimeZone 用来表示 时区偏移量 下面来... -
The server time zone value 'EDT' is unrecognized or represents more than one time zone.
2017-03-13 18:37:38问题: ...Caused by: java.sql.SQLException: The server time zone value 'EDT' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via -
解决:The server time zone value '�й���ʱ��' is unrecognized or represents more than one ...
2020-03-19 09:00:55解决问题:The server time zone value ‘�й���ʱ��’ is unrecognized or represents more ... You must configure either the server or JDBC driver (via the serverTimezone configuration property) t... -
Server returns invalid timezone. Go to Advanced tab and set serverTimezone property manually.
2020-05-24 19:23:27Serverreturnsinvalidtimezone.Goto'Advanced'tabandset'serverTimezone'propertymanually. 提示的内容是: Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property ... -
IDEA 配置连接数据库报错 Server returns invalid timezone. Need to set ‘serverTimezone‘ property.
2020-08-14 09:44:27IDEA 配置连接数据库报错 Server returns invalid timezone. Need to set ‘serverTimezone’ property. 原因是MySQL驱动中默认时区是UTC,与本地时间(中国)相差八个小时,所以链接不上。 可以用两种方法解决,都... -
IDEA中配置MySQL出现Server returns invalid timezone问题解决方法
2019-09-07 16:43:00原因: 首先,出现该问题的原因是MySQL驱动jar中的默认时区是UTC。...因为时区不一致,所以提示Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually 服务器... -
PyCharm Database serverTimezone
2020-03-01 10:12:03PyCharm Database serverTimezone PyCharm中有提供视图化的数据库工具——Database,在使用这个工具的时候,因为时区设置的问题,会导致连接不成功。 报错信息如下: Server returns invalid timezone. Go to '... -
Server returns invalid timezone. Need to set ‘serverTimezone‘ property. Idea连接mysql报错问题
2020-10-02 13:02:51Server returns invalid timezone. Need to set 'serverTimezone' property. Idea连接mysql报错问题 这是时区错误 在url后添加:?serverTimezone=GMT%2B8 -
idea连接mysql数据库报错 Server returns invalid timezone. Need to set ‘serverTimezone‘ property.
2020-07-25 18:21:10idea连接mysql数据库报错 Server returns invalid timezone. Need to set ‘serverTimezone’ property. 解决办法: (1)打开mysql命令行,输入show variables like’%time_zone’; 如下所示: mysql> show ... -
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually.
2019-12-24 11:11:14Server returns invalid timezone. Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually. 错误 Server returns invalid timezone. Go to ‘Advanced’ tab and set ‘serverTimezone’ propert... -
错误:The server time zone value is unrecognized or represents more than one time zone
2019-07-18 17:08:04您必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)使用一个更具体的时区值如果你想利用时区支持。 在通过在数据库连接URL后,加上?serverTimezone=UTC 为什么是UTC 环境需要:如要维护多国环境如中美,... -
The server time zone value 'unknown' is unrecognized or represents more than one time zone
2020-02-19 10:39:19在连接字符串增加serverTimezone定义就可以了。 spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_job?Unicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8 -
IDEA连接数据库报错Server returns invalid timezone. Need to set‘serverTimezone’property问题解决
2020-12-10 11:51:47方法一: 打开cmd进入数据库 输入 set global time_zone = ‘+8:00’; set time_zone = ‘+8:00’; flush privileges; ...将serverTimezone 的Value属性修改为GMT ...在URL后添加serverTimezone=GMT%2B8
-
【2021】Python3+Selenium3自动化测试(不含框架)
-
阿里云云计算ACP考试必备教程
-
php实现简单的用户注册,登录,修改个人信息接口
-
云计算基础-Linux系统管理员
-
CUnit CUnit CUnit CUnit CUnit CUnit
-
python办公自动化技巧
-
Java学习路线,好的学习路线和好的方法,能让我们少走些弯路
-
新闻列表页的制作
-
API代理版自动发卡平台源码V4.5.6.zip
-
FPGA 之 SOPC 系列(五)Nios II 软件使用与程序开发 I
-
jdk api 1.8.zip
-
JDK里面自带了这么多的exe,你都挨着试过么?
-
web前端开发规范
-
CPP-Summit 2019 - 李永顺 - 嵌入式系统C++性能优化.pdf
-
华为Mate10Pro维修图PCB位置图(PDF格式)
-
【2021】UI自动化测试Selenium3
-
我的Git笔记.pdf
-
十年老码农深入浅出让你彻底明白sql注入攻击
-
securecrt一款好用的终端仿真程序
-
新一轮5G建设招标开启