【errors】The server time zone value is unrecognized or represents more than one time zone.

本文详细解析了在连接JDBC时遇到的关于服务器时区值无法识别或代表多个时区的错误,并提供了解决方案,即在连接字符串中明确指定时区。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

连接JDBC运行程序时出现:
java.sql.SQLException: 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 com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:455)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.example.sql.JDBCdemo.main(JDBCdemo.java:18)
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)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2241)
at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2265)
at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1319)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:966)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825)
… 6 more

解释为:
服务器时区值’???ú±ê×??±??'无法识别或代表多个时区。如果要使用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值。

解决

在getConnection(String url, String user, String password)函数url参数中加入 serverTimezone=GMT:

String url = "jdbc:mysql://localhost:3306/sakila
			useUnicode=true
			&characterEncode=UTF8
			&serverTimezone=GMT";
debezium的connector配置:{ "name": "pi_dressin_mysql_connector_fit_1749525000", "config": { "connector.class": "io.debezium.connector.mysql.MySqlConnector", "datetime.format.datetime": "yyyy-MM-dd HH:mm:ss", "database.history.kafka.topic": "dressin_bi_debezium_history", "database.history.producer.compression.type": "lz4", "include.schema.changes": "true", "datetime.format.timestamp": "yyyy-MM-dd HH:mm:ss", "decimal.handling.mode": "string", "database.history.store.only.captured.tables.ddl": "true", "converters": "datetime", "datetime.type": "com.darcytech.debezium.converter.MySqlDateTimeConverter", "datetime.format.timestamp.zone": "UTC", "database.user": "pi_select", "database.dbname": "dressin_bi", "database.server.id": "1749525000", "database.history.kafka.bootstrap.servers": "aws-canal-server:9092", "database.server.name": "dressin_bi_ddl", "datetime.format.date": "yyyy-MM-dd", "database.port": "3306", "database.hostname": "20.43.247.39", "datetime.format.time": "HH:mm:ss", "database.password": "H,k}M]T19~#NY?TMi", "name": "pi_dressin_mysql_connector_fit_1749525000", "table.include.list": "dressin_bi.ads_ana_dimall_offline_boss_category_sales_rank_n_n,dressin_bi.ads_ana_dimall_offline_boss_sales_metric_n_n,dressin_bi.dws_trade_everysite_repurchase_metrics_mi,dressin_bi.", "include.query": "true", "database.include.list": "dressin_bi", "snapshot.mode": "when_needed" } }报错:{ "error_code": 400, "message": "Connector configuration is invalid and contains the following 1 error(s):\nUnable to connect: The server time zone value 'CDT' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 'connectionTimeZone' configuration property) to use a more specific time zone value if you want to utilize time zone support.\nYou can also find the above list of errors at the endpoint `/connector-plugins/{connectorType}/config/validate`" }
06-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值