阅读时间: 1分钟
相信大家在使用JDBC连接MySql时都有可能出现各种问题,
现在就为大家解决其中一个可能会遇到的问题。
报错的讯息:
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
原因:
输入中文字型时会出现以上错误讯息
解决方法:
需要修改文件:application.properties
位置:src/main/resources/application.properties
加入语法: useUnicode=true&characterEncoding=UTF-8
For MySQL Connection
spring.datasource.url=jdbc:mysql://localhost:3306/sys?serverTimezone=UTC&useSSL=falsespring.datasource.username=rootspring.datasource.password=rootspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driverspring.http.encoding.force=true
For MySQL Connection
spring.datasource.url=jdbc:mysql://localhost:3306/sys?serverTimezone=UTC&useSSL=false& useUnicode=true&characterEncoding=UTF-8spring.datasource.username=rootspring.datasource.password=rootspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driverspring.http.encoding.force=true