Java - 使用JDBC连接MySql时出现的报错: The server time zone value ...

Java - 使用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

打开application.properties

# For MySQL Connectionspring.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 Connectionspring.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

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章