Loading class `com.mysql.jdbc.Driver'. This is

2020-05-19 02:08发布

This is the Warning im getting in console, Im confused with this warning

Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

标签: mysql jdbc
19条回答
We Are One
2楼-- · 2020-05-19 02:50

working example:

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/your_db_name?autoReconnect=true&useSSL=false", "root", "root");

call like this it will work.

查看更多
等我变得足够好
3楼-- · 2020-05-19 02:51

Changed my application.conf file as below. It solved the problem.

Before Change:

slick {
  dbs {
    default {
      profile = "slick.jdbc.MySQLProfile$"
      db {
        driver = "com.mysql.jdbc.Driver"
        url = "jdbc:mysql://localhost:3306/test"
        user = "root"
        password = "root"
      }
    }
  }
}

After Change:

slick {
  dbs {
    default {
      profile = "slick.jdbc.MySQLProfile$"
      db {
        driver = "com.mysql.cj.jdbc.Driver"
        url = "jdbc:mysql://localhost:3306/test"
        user = "root"
        password = "root"
      }
    }
  }
}
查看更多
Rolldiameter
4楼-- · 2020-05-19 02:55

in my case, I had a line Class.forName("com.mysql.jdbc.Driver"); after removing this line code works fine if you have any line for loading "com.mysql.jdbc.Driver" remove it, it doesn't require any more

查看更多
\"骚年 ilove
5楼-- · 2020-05-19 02:57

In case of using a configuration based on a YML file, the following will be the property that needs to be adjusted inside the given file:

*driverClassName: com.mysql.cj.jdbc.Driver*

查看更多
来,给爷笑一个
6楼-- · 2020-05-19 02:58

According Changes in the Connector/J API "The name of the class that implements java.sql.Driver in MySQL Connector/J has changed from com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver. The old class name has been deprecated."

This means that you just need to change the name of the driver:

Class.forName("com.mysql.jdbc.Driver");

to

Class.forName("com.mysql.cj.jdbc.Driver");
查看更多
别忘想泡老子
7楼-- · 2020-05-19 02:58

my solution: org.springframework.boot 2.0.5.RELEASE

Rather: org.springframework.boot 2.1.0.RELEASE

查看更多
登录 后发表回答