前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >mysql驱动参数变化

mysql驱动参数变化

作者头像
编程随笔
发布2019-09-11 16:01:08
2K0
发布2019-09-11 16:01:08
举报
文章被收录于专栏:后端开发随笔后端开发随笔

在java平台使用的mysql jdbc驱动为:mysql-connector-java。 在项目中添加如下依赖:

代码语言:javascript
复制
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>${version.mysql.connector}</version>
</dependency>

在6.0.2版本之前

代码语言:javascript
复制
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://host:port/dbname?characterEncoding=utf8

在6.0.2版本之后

代码语言:javascript
复制
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://host:port/dbname?characterEncoding=utf8&serverTimezone=UTC

mysql-connector-java参数变化

1.从6.0.2版本开始,驱动类不再是com.mysql.jdbc.Driver,需要配置为:com.mysql.cj.jdbc.Driver。 否则,在启动时会提示警告日志:

代码语言:javascript
复制
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

2.从6.0.2版本开始,如果mysql server未明确配置时区,则必须在jdbc连接参数中设置serverTimezone。 否则,在启动时报错:

代码语言:javascript
复制
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: 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.
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-10-18 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 在6.0.2版本之前
  • 在6.0.2版本之后
  • mysql-connector-java参数变化
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档