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/ ...
随机推荐
- [正则表达式]匹配Unicode
一.PHP[PCRE]之Unicode PCRE支持的16进制字符编码转义符有 \x00-\xFF,或\x{num},num为任意位16进制数 但并不支持\u0000-\uFFFF这的形式 PCRE运 ...
- PHP针对数字的加密解密类,可直接使用
<?phpnamespace app;/** * 加密解密类 * 该算法仅支持加密数字.比较适用于数据库中id字段的加密解密,以及根据数字显示url的加密. * @author 深秋的竹子 * ...
- vue v-show绑定
在Vue中使用v-show指令来选择性的显示内容.它的属性值可以是布尔值.属性名称以及函数名称.如果使用函数来控制的话,无论函数内容如何运算判断,最终返回布尔值true或者false就可以了 < ...
- Android性能优化:手把手带你全面实现内存优化
前言 在 Android开发中,性能优化策略十分重要 本文主要讲解性能优化中的内存优化,希望你们会喜欢 目录 1. 定义 优化处理 应用程序的内存使用.空间占用 2. 作用 避免因不正确使用内 ...
- Confluence 6 Windows 中以服务方式自动重启修改运行服务的用户
基于安全的考虑,如果你希望你的 Confluence 不是在系统中以管理员的身份运行或者你使用网络驱动器来存储备份,附件和索引的话,你可以以其他用户来运行 Confluence. 希望修改用户,打开 ...
- Confluence 6 管理员联系表单的后台配置界面
管理员联系表单的后台配置界面截图和配置. 对输入的数据进行编辑和选择是否启用发送电子邮件给管理员 https://www.cwiki.us/display/CONFLUENCEWIKI/Configu ...
- map函数和reduce函数的区别
①从参数方面来讲:map()函数: map()包含两个参数,第一个是参数是一个函数,第二个是序列(列表或元组).其中,函数(即map的第一个参数位置的函数)可以接收一个或多个参数.reduce()函数 ...
- 课外知识----base64加密
每3个字符产生4位的base64字符,不足3个字符,将用“=”补齐至4位base64字符 例如 00---> MDA= 000--->MDAw base64加密特点 加密后的字符数是4的 ...
- Repair the Wall
问题 : Repair the Wall 时间限制: 1 Sec 内存限制: 128 MB 题目描述 Long time ago , Kitty lived in a small village. ...
- selenium 操作键盘
send_keys(Keys.ENTER) 按下回车键send_keys(Keys.TAB) 按下Tab制表键send_keys(Keys.SPACE) 按下空格键spacesend_keys(Kye ...