mysql的驱动类com.mysql.jdbc.Driver过时了,需要用com.mysql.cj.jdbc.Driver代替

springboot项目整合mybatis,配置文件如下:

server:
  port: 8081
mybatis:
  config-location: classpath:mybatis/mybatis-config.xml   #mybatis配置文件所在路径
  type-aliases-package: com.yuanqiao.entities     #所有entity别名类所在包
  mapper-locations: classpath:mybatis/mapper/*.xml
spring:
  application:
    name: swaggerdemo
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
    username: root
    password: 123456
    dbcp2:
      min-idle: 5         #数据库连接池的最小维持连接数
      initial-size: 5      #初始化连接数
      max-total: 5            #最大连接数
      max-wait-millis: 200      #等待连接获取的最大超时时间

做sql查询的时候,提示com.mysql.jdbc.Driver已经弃用了。

Creating a new SqlSession
SqlSession [[email protected]] was not registered for synchronization because synchronization is not active
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.
2019-07-20 16:16:42.533 INFO 59084 --- [nio-8081-exec-2] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited
JDBC Connection [[email protected]] will not be managed by Spring
==> Preparing: select * from user where id = ?
==> Parameters: 1(Integer)
<== Columns: id, name, sex, age
<== Row: 1, zhangsan, male, 22
<== Total: 1
Closing non transactional SqlSession [[email protected]]

原文地址:https://www.cnblogs.com/mkl34367803/p/11218145.html

时间: 2024-10-01 02:41:22

mysql的驱动类com.mysql.jdbc.Driver过时了,需要用com.mysql.cj.jdbc.Driver代替的相关文章

com.mysql.jdbc.Driver ==》 com.mysql.cj.jdbc.Driver

错误信息: SqlSession [[email protected]] was not registered for synchronization because synchronization is not active Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatical

java.lang.UnsupportedClassVersionError: com/mysql/cj/jdbc/Driver : Unsupported major.minor version 5

原因: com/mysql/cj/jdbc/Driver是6.0版本的驱动,兼容JDK8环境,不兼容JDK7环境,在基于jdk7的tomcat中编译运行会出错,在基于jdk8的tomcat中编译运行则不会出错. 解决方案: 1.jdk7+老版5.0驱动com/mysql/jdbc/Driver 2.jdk8+新版6.0驱动com/mysql/cj/jdbc/Driver 原文地址:https://www.cnblogs.com/GH0522/p/9328416.html

MyBatis Generator使用com.mysql.cj.jdbc.Driver遇到的问题

MyBatis Generator使用com.mysql.cj.jdbc.Driver Mybatis Generator 1.3.5 新建了一个decision库,并创建了一张user表 import org.apache.commons.lang3.StringUtils; import org.mybatis.generator.api.MyBatisGenerator; import org.mybatis.generator.config.*; import org.mybatis.g

JDBC 加载mysql数据库驱动

第一步:下载 mysq l驱动 Connctor/J 就是为Java 的JDBC准备的 下载完毕后,解压后,会看见如下图的就是mysql驱动的 jar 包: (二)打开Eclipse,新建java工程,然后新建一个文件夹(改名为lib) 然后把 mysql驱动的jar包 复制到该文件夹下:(点击新建的文件夹ctrl+v粘贴就行) (三)对 mysql的驱动 jar包 右键,把他加入到工程 出现下图时,则完成操作. 一.前言: 之前的一篇笔记是关于安装MySQL数据库和SQLyog数据库可视化工具

解决Loading class `com.mysql.jdbc.Driver&#39;. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver&#39;.

异常: Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. 整合spring boot项目过程中出现的,用了最新的mysql 连接驱动 application-dev.properties spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=

Loading class `com.mysql.jdbc.Driver&#39;. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver&#39;.

在连接数据库时,使用了最新版本的mysql-Connector,所以导致老版本的"com.mysql.jdbc.Drive"不可行,要改为"com.mysql.cj.jdbc.Driver" Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. 原文地址:https://www.cnblogs.com

com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的区别

调试代码时,发现错误: 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. 在网上巴拉巴拉发现,原

java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver

java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) at java

com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的区别 serverTimezone设定

问题: com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的区别 serverTimezone设定 com.mysql.jdbc.Driver 是 mysql-connector-java 5中的, com.mysql.cj.jdbc.Driver 是 mysql-connector-java 6中的 1.JDBC连接Mysql5 com.mysql.jdbc.Driver: driverClassName=com.mysql.jdbc.Driver