简体   繁体   English

mysql-connector-java-8.0.12:获取“马来半岛标准时间”服务器时区错误

[英]mysql-connector-java-8.0.12 : getting error for 'Malay Peninsula Standard Time' server time zone

We recently upgraded MySQL from 5.6 to 8. So, as per upgrade instructions,using mysql-java-connector(8.0.12) and new driver class name ie com.mysql.cj.jdbc.Driver in database url.我们最近将 MySQL 从 5.6 升级到 8。因此,按照升级说明,在数据库 url 中使用mysql-java-connector(8.0.12)和新的驱动程序类名称,即com.mysql.cj.jdbc.Driver But Getting below error only for this time zone 'Malay Peninsula Standard Time'但是仅在此时区“马来半岛标准时间”中出现错误

java.sql.SQLException: Cannot create PoolableConnectionFactory (The server time zone value 'Malay Peninsula Standard Time' 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.) Related cause: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'dynamicEntityManagerFactory': FactoryBean which is currently in creation returned null from getObject at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:378) ............... .............. Caused by: java.sql.SQLException: The server time zone value 'Malay Peninsula Standard Time' is unrecognized or represents more than one time zone. java.sql.SQLException: 无法创建 PoolableConnectionFactory(服务器时区值“马来半岛标准时间”无法识别或代表多个时区。您必须配置服务器或 JDBC 驱动程序(通过 serverTimezone 配置属性)才能使用如果您想利用时区支持,则需要更具体的时区值。)相关原因:org.springframework.beans.factory.BeanCurrentlyInCreationException:创建名为“dynamicEntityManagerFactory”的 bean 时出错:当前正在创建的 FactoryBean 从 org 的 getObject 返回 null。 springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:378) ......................... 引起: java.sql.SQLException:服务器时区值“马来半岛标准时间”无法识别或代表多个时区。 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.如果您想利用时区支持,您必须将服务器或 JDBC 驱动程序(通过 serverTimezone 配置属性)配置为使用更具体的时区值。 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)在 com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)

using below configuration to create connections in tomcat context.xml使用以下配置在 tomcat context.xml 中创建连接

<Resource auth="Container" driverClassName="com.mysql.cj.jdbc.Driver" factory="com.grc.common.EncryptedDataSourceFactory" maxActive="100" maxIdle="30" maxWait="10000" minEvictableIdleTimeMillis="30000" minIdle="10" name="jdbc/TestDB" password="0df9f21ee02a561fa39f18f5c7581061" removeAbandoned="true" removeAbandonedTimeout="180" testOnBorrow="true" testOnReturn="false" testWhileIdle="true" timeBetweenEvictionRunsMillis="30000" type="javax.sql.DataSource" url="jdbc:mysql://127.0.0.1:3306/production1?useSSL=false" username="root" validationInterval="30000" validationQuery="SELECT 1"/>

Also, tried with serverTimezone parameter like below, but no luck.此外,尝试使用如下所示的 serverTimezone 参数,但没有运气。

<Resource auth="Container" driverClassName="com.mysql.cj.jdbc.Driver" factory="com.grc.common.EncryptedDataSourceFactory" maxActive="100" maxIdle="30" maxWait="10000" minEvictableIdleTimeMillis="30000" minIdle="10" name="jdbc/TestDB" password="0df9f21ee02a561fa39f18f5c7581061" removeAbandoned="true" removeAbandonedTimeout="180" testOnBorrow="true" testOnReturn="false" testWhileIdle="true" timeBetweenEvictionRunsMillis="30000" type="javax.sql.DataSource" url="jdbc:mysql://127.0.0.1:3306/production1?useSSL=false&amp;serverTimezone=Malay Peninsula Standard Time" username="root" validationInterval="30000" validationQuery="SELECT 1"/>

I resolved myself without changing any registry at OS level.我自己解决了,没有在操作系统级别更改任何注册表。 This may help others.这可能会帮助其他人。

Getting this error since Time zone name with 'Malay Peninsula Standard Time' is not available in MySQL.收到此错误是因为 MySQL 中不提供带有“马来半岛标准时间”的时区名称。 So as instructed in this MySQL Documenation , downloaded timezone_2018e_posix_sql.zip from this MySQL Timezones and loaded into MySQL database as instructed.所以按照这个MySQL 文档中的指示,从这个MySQL Timezones下载timezone_2018e_posix_sql.zip并按照指示加载到 MySQL 数据库中。 After that added below configuration in my.ini file and restarted the server.之后在 my.ini 文件中添加以下配置并重新启动服务器。

default_time_zone=Asia/Singapore

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM