Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'

前端 未结 20 2424
予麋鹿
予麋鹿 2020-12-13 06:02

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 is         


        
相关标签:
20条回答
  • 2020-12-13 06:21

    This is beacuse the version of mysql to be connected is lower than the version of the mysql driver. Many people say that com.mysql.jdbc.Driver is changed to com.mysql.cj.jdbc.Driver , although this does not solve the problem, but it should also attract attention.

    0 讨论(0)
  • 2020-12-13 06:22
            // The newInstance() call is a work around for some
            // broken Java implementations
            Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
    
    0 讨论(0)
  • 2020-12-13 06:22

    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"
          }
        }
      }
    }
    
    0 讨论(0)
  • 2020-12-13 06:22

    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

    0 讨论(0)
  • 2020-12-13 06:23

    If seeing this message in Hive with new MySQL connector 8.x (MySQL metastore)

    open hive-site.xml and change:

       <property>
          <name>javax.jdo.option.ConnectionDriverName</name>
          <value>com.mysql.jdbc.Driver</value>
          <description>MySQL JDBC driver class</description>
       </property>
    

    to

       <property>
          <name>javax.jdo.option.ConnectionDriverName</name>
          <value>com.mysql.cj.jdbc.Driver</value>
          <description>MySQL JDBC driver class</description>
       </property>
    
    0 讨论(0)
  • 2020-12-13 06:27

    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.

    0 讨论(0)
提交回复
热议问题