错误描述
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
网友评论