美文网首页程序员
MySql错误:java.sql.SQLException: T

MySql错误:java.sql.SQLException: T

作者: 世外大帝 | 来源:发表于2020-04-29 19:30 被阅读0次

错误描述

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.

原因

由于时差的问题,导致数据库无法准确识别时区,所以 MySQL jdbc 6.0 版本以上必须配置此参数,否则报错如上。

url=jdbc:mysql://localhost:3306/transaction?serverTimezone=UTC

UTC 为世界标准时间,以格林尼治时间为准,与北京时间相差8个小时。

解决方案

国内可使用

url=jdbc:mysql://localhost:3306/transaction?serverTimezone=Asia/Shanghai

其他url问题

设置编码格式:characterEncoding=utf8

关闭ssl警告:useSSL=false

批量执行:rewriteBatchedStatements=true

characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true

相关文章

网友评论

    本文标题:MySql错误:java.sql.SQLException: T

    本文链接:https://www.haomeiwen.com/subject/itnnwhtx.html