mySql版本的相关问题:com.mysql.cj.jdbc.Driver和com.mysql.jdbc.Driver
MySQL版本的相关问题:com.mysql.cj.jdbc.Driver和com.mysql.jdbc.Driver
1. 在使用mysql时,控制台日志报错如下:
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.
报错原因:
MySQL5用的驱动url是com.mysql.jdbc.Driver,MySQL6以后用的是com.mysql.cj.jdbc.Driver。版本不匹配便会报驱动类已过时的错误。
解决方法:
更改配置文件中的驱动类名字就可以消除驱动类过时的警告了。 2. JDBC连接MySQL6 (com.mysql.cj.jdbc.Driver), 需要指定时区serverTimezone,否则会报如下错误:
org.mybatis.spring.MyBatisSystemException:
nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException:
Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException:
Cannot create PoolableConnectionFactory (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.)
3.还有一个警告:
WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
/**
不推荐不使用服务器身份验证来建立SSL连接。
如果未明确设置,MySQL 5.5.45+, 5.6.26+ and 5.7.6+版本默认要求建立SSL连接。
为了符合当前不使用SSL连接的应用程序,verifyServerCertificate属性设置为’false’。
如果你不需要使用SSL连接,你需要通过设置useSSL=false来显式禁用SSL连接。
如果你需要用SSL连接,就要为服务器证书验证提供信任库,并设置useSSL=true。
**/
名词解释:
SSL – Secure Sockets Layer(安全套接层)
所以,使用mysql6的连接字符串建议使用如下:
jdbc.url=jdbc:mysql://localhost:3306/your_database?characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false
//更详细的连接字符创参考: mysql.url=jdbc:mysql://127.0.0.1:3306/dbname?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&verifyServerCertificate=false&autoReconnct=true&autoReconnectForPools=true&allowMultiQueries=true
以上配置的写法是写在单独的配置文件properties中,使用xml文件配置的写法略有不同,需要将每一个配置用分号; 隔开,需要注意的是分号;在xml中需要转义。XML文件中的写法:
<property name="url" value="jdbc:mysql://localhost/lujx?serverTimezone=UTC&useSSL=false" />
mySql版本的相关问题:com.mysql.cj.jdbc.Driver和com.mysql.jdbc.Driver的更多相关文章
- mysql 版本引起的 utf8mb4 问题(linux centos6.9下升级mysql)
文字输入时候存在火星文或者表情,insert到低版本的mysql中一般会报错,所以我们需要将mysql版本升级到5.5.3及以上,高版本的mysql为我们提供了utf8mb4的编码,解决了这些复杂数据 ...
- Mysql版本java问题(com.mysql.cj.jdbc.Driver和com.mysql.jdbc.Driver)
老版本com.mysql.jdbc.Driver已弃用 String url1 = "jabc:mysql://127.0.0.1:3306/test"; String url1 ...
- 实战分享丨MySQL 与Django版本匹配相关经验
摘要:关于MySQL 与Django版本匹配相关知识的经验分享. run: (env) E:\PythonPro\PyDjangoProDemo011\xuanyuaniotpro>python ...
- MySQL版本调研
1引言 1.1 编写目的 本文的主要目的是通过对当前项目中使用的各种版本的数据库进行比较,分析各自特性和稳定程度,最终推荐合适的版本作为今后的标准数据库. 1.2 背景 当前,部门负责管理维护的现网使 ...
- CentOS6.x升级MySQL版本5.1到5.6
CentOS6.x升级MySQL版本5.1到5.6 分类: Web MySQL 2014-08-04 11:22 2813人阅读 评论(1) 收藏 举报 mysql云服务器升级centos6 有一些虚 ...
- com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的区别 serverTimezone设定
转自: http://blog.csdn.net/superdangbo/article/details/78732700 com.mysql.jdbc.Driver 和 com.mysql.cj.j ...
- com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的区别
com.mysql.jdbc.Driver 是 mysql-connector-java 5中的,com.mysql.cj.jdbc.Driver 是 mysql-connector-java 6中的 ...
- 云服务器 ECS > 建站教程 > 部署 LAMP (CentOS 7.2 ,Apache版本:2.4.23, Mysql 版本:5.7.17 , Php版本:7.0.12)
云服务器 ECS > 建站教程 > 部署 LAMP (CentOS 7.2) 部署 LAMP (CentOS 7.2) 文档提供方:上海驻云信息科技有限公司 更新时间:2017-06 ...
- MySQL版本详解
一.版本说明 1.1.MySQL相关连接 MySQL官网:https://www.mysql.com/ MySQL下载:https://dev.mysql.com/downloads/mirrors/ ...
随机推荐
- 前端 -----jQuery的事件绑定和解绑
11-jQuery的事件绑定和解绑 1.绑定事件 语法: bind(type,data,fn) 描述:为每一个匹配元素的特定事件(像click)绑定一个事件处理器函数. 参数解释: type (S ...
- ubuntu18.04安装xmind8
1.先去官网下载:https://www.xmind.net/download/xmind8/ 2.默认下载到/home/guojihai/下载/目录下然后把xmind-8-update8-linux ...
- Affiliate实战记录之一:CPI、CPA、CPM...名词解释
1.CPM (Cost Per Mille,或者Cost Per Thousand;Cost Per Impressions) 每千人成本,按展示次数收费 网上广告收费最科学的办法是按照有多少人看到你 ...
- select下拉框插件jquery.editable-select
项目中有个需求,下拉框既可以下拉选择,也可以手动填写 html代码 <span>数据来源</span> </select> js代码 $('#noMean').ed ...
- Modbus库开发笔记:Modbus ASCII Master开发
这一节我们来封装Modbus ASCII Master应用,Modbus ASCII主站的开发与RTU主站的开发是一致的.同样的我们也不是做具体的应用,而是实现ASCII主站的基本功能.我们将ASCI ...
- Confluence 6 修改日志文件的目标位置
在 log4j 中,一个输出被定义为 'appender'.希望修改 log 文件的目标,你需要停止 Confluence 然后修改设置 log4j.properties 日志配置文件的 'Logg ...
- LeetCode(101):对称二叉树
Easy! 题目描述: 给定一个二叉树,检查它是否是镜像对称的. 例如,二叉树 [1,2,2,3,4,4,3] 是对称的. 1 / \ 2 2 / \ / \ 3 4 4 3 但是下面这个 [1,2, ...
- JumpServer里的sftp功能报错说明
JumpServer里sftp默认的家目录是/tmp下 修改默认家目录: vim /usr/local/coco/coco/sftp.py class SFTPServer(paramiko.SFTP ...
- linux学习笔记之 basename, dirname
前言: basename: 用于打印目录或者文件的基本名称 dirname: 去除文件名中的非目录部分,仅显示与目录有关的内容.dirname命令读取指定路径名保留最后一个/及其后面的字符,删除其他部 ...
- oracle 12c ORA-01017:invalid username/password; logon denied
Oracle 12C 中,想通过操作系统认证登录Oracle 数据库,有一些要注意的地方.不然就会遇到 ORA-01017:invalid username/password; logon denie ...