JDBC driver (via the ‘serverTimezone‘ configuration property)
2021/9/23 23:11:04
本文主要是介绍JDBC driver (via the ‘serverTimezone‘ configuration property),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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 specific time zone value if you want to utilize time zone support.
出现这个异常的原因:
因为安装mysql的时候时区设置的不正确 mysql默认的是美国的时区,而我们中国大陆要比他们迟8小时,采用+8:00格式
解决:在url的地址上加一个参数?serverTimezone=UTC
url: jdbc:mysql://localhost:3306/telecom?serverTimezone=UTC
如果在程序中输入的汉字写到数据库是乱码
1.首先看自己程序的编码是否是utf-8
2.若程序的编码和我们数据库的编码不一也会出现
解决:在URL加一个useUnicode=true&characterEncoding=utf-8来解决中
url: jdbc:mysql://localhost:3306/telecom?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8
如果涉及多个批量插入的时候url需要加这个参数
需修改url=jdbc:mysql://localhost:3306/lanqiao?allowMultiQueries=true,否则报错
&allowMultiQueries=true
如果出现Communications link failure这个异常
Error querying database. Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
解决:url加一个useSSL=false的参数
useSSL=false
这篇关于JDBC driver (via the ‘serverTimezone‘ configuration property)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-04el-table 开启定时器下,表格的选中状态会消失是什么原因-icode9专业技术文章分享
- 2024-10-03如何安装和初始化飞牛私有云 fnOS?-icode9专业技术文章分享
- 2024-10-03如何安装 App 并连接到飞牛 NAS?-icode9专业技术文章分享
- 2024-10-03如何安装飞牛 TV 并连接到影视服务器?-icode9专业技术文章分享
- 2024-10-03如何在PVE和ESXI上安装飞牛私有云 fnOS?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS安装系统异常情况处理-icode9专业技术文章分享
- 2024-10-03飞牛NAS如何创建存储空间?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS硬盘会自动休眠吗?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS如何安装飞牛影视和创建媒体库?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS如何为家人朋友开通影视账号?-icode9专业技术文章分享