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
- timestamp with local time zone型別和timestamp with time zone型別
- Clock in a Linux Guest Runs More Slowly or Quickly Than Real TimeLinuxUI
- 6、TIMESTAMP WITH TIME ZONE和TIMESTAMP WITH LOCAL TIME ZONE的實踐理解
- More than one file was found with OS independent path
- oracle 10.2.0.1 emctl Timezone mismatch: The agentTZRegion value (US/Eastern)OracleAST
- oracle之time zone時區timestamp with time zone相關的概念之一Oracle
- JavaScript getTimezoneOffset()JavaScript
- oracle time_zone!Oracle
- Oracle TimezoneOracle
- 解決問題:Variable 'time_zone' can't be set to the value of 'NULL'Null
- TIMESTAMP和TIMESTAMP WITH TIME ZONE之間的總結
- ORACLE 時間與時區(Time and Time Zone)Oracle
- android: ADB錯誤“more than one device and emulator”Androiddev
- oracle time_zone(zt)Oracle
- 轉:Oracle TimeZoneOracle
- oracle plsql定義date_timestamp_with time zoneOracleSQL
- Server returns invalid timezone. Need to set ‘serverTimezone‘ property. Idea連線mysql報錯問題ServerIdeaMySql
- Need to set ‘serverTimezone‘ propertyServer
- Setting the Database Time Zone (80)Database
- Unable to convert MySQL date/time value to System.DateTimeMySql
- Getting NOW() in your preferred time zone
- Specifying the Database Time Zone File (81)Database
- ORA-39322: Cannot use transportable tablespace with timestamp with timezone...
- BUG: JS 修改Date的TimezoneJS
- Oracle的時區問題Time ZoneOracle
- redhat 5.5 time zone configurationRedhat
- DNS: More than just namesDNS
- [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.explicit_defaults_for_timestamp
- Oracle timezone的相關知識Oracle
- mysql出現Unknown or incorrect time zone: 'NULL'MySqlNull
- Syntax error, unrecognized expression: li[value=]ErrorZedExpress
- Java新增構造方法異常異常——Could not autowire. there is more than one bean of '' typeJava構造方法Bean