JDBC:The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone.
背景
今天專案切換到了mysql8.0.12,結果還多了一個報錯,看來8和5.7的差別還真大。。。煩煩煩。。。
com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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.
就是說mysql的伺服器時區無法識別或存在/代表多個時區。您必須在JDBC的URL指定serverTimezone=UTC
來解決這個問題=。=
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_222]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_222]
at sun.reflect.DelegatingConstructorAccessorImpl.__newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_222]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45009) ~[?:1.8.0_222]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45012) ~[?:1.8.0_222]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_222]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.16.jar:8.0.16]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85) ~[mysql-connector-java-8.0.16.jar:8.0.16]
at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132) ~[mysql-connector-java-8.0.16.jar:8.0.16]
at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2243) ~[mysql-connector-java-8.0.16.jar:8.0.16]
at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2267) ~[mysql-connector-java-8.0.16.jar:8.0.16]
at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1319) ~[mysql-connector-java-8.0.16.jar:8.0.16]
at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:868) ~[mysql-connector-java-8.0.16.jar:8.0.16]
... 10 more
Solution
於是我的jdbc url就變得無比的長。。。解決以上問題需要加多一個&serverTimezone=UTC
url: jdbc:mysql://localhost:3306/mcms?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true&serverTimezone=UTC
相關文章
- 異常解決——The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than oneServerZed
- mysql執行報The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one tim......MySqlServerZed
- java.sql.SQLException: The server time zone value ‘???ú±ê×??±??‘ is unrecognized or represents moreJavaSQLExceptionServerZed
- spring boot 啟動時報錯The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized orJDBC driverSpring BootServerZedJDBC
- java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognized...報錯解決JavaSQLExceptionServerZed
- Idea資料庫引入異常:java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognizedIdea資料庫JavaSQLExceptionServerZed
- Invalid time zone indicator ‘ ‘Indicator
- oracle time_zone(zt)Oracle
- 解決問題:Variable 'time_zone' can't be set to the value of 'NULL'Null
- Getting NOW() in your preferred time zone
- More than one file was found with OS independent path
- Oracle的時區問題Time ZoneOracle
- JavaScript Promise Time Limit Function All In OneJavaScriptPromiseMITFunction
- TIMESTAMP和TIMESTAMP WITH TIME ZONE之間的總結
- `jsonb` 報錯 `invalid input syntax for type timestamp with time zone ““JSON
- 解決ERROR 1231 (42000): Variable 'time_zone' can'tError
- DNS: More than just namesDNS
- [20241009]oracle timestamp with time zone資料型別的儲存.txtOracle資料型別
- time time_t tm用法
- Cipher005__ 史丹佛密碼學__The One Time Pad密碼學
- Java新增構造方法異常異常——Could not autowire. there is more than one bean of '' typeJava構造方法Bean
- Syntax error, unrecognized expression: li[value=]ErrorZedExpress
- JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from StringJSONErrorJavaLDA
- DREAM TIME
- 20 compliments that needs to be said to my girl from time to timeAI
- 題解:AT_abc345_c [ABC345C] One Time Swap
- OpenKruise 2021 規劃曝光:More than workloadsUI
- Aheadof Time Compilation(AOT) vs (JIT)Just In Time compilation approachAPP
- python parse timePython
- Time Series DatabasesDatabase
- jenkins trigger by timeJenkins
- 備忘錄:SQL SERVER2014 出現:“Cannot find one or more components”SQLServer
- GORM 自定義time.time日期時間輸出格式GoORM
- 時區提示:Local time zone must be set--see zic manual page 2018的解決辦法
- 【mysql】關於連線mysql資料庫時出現的時區錯誤time zoneMySql資料庫
- [LeetCode] Employee Free TimeLeetCode
- Oracle Cluster Time ManagementOracle
- HTML <time> 標籤HTML