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条回答
手持菜刀,她持情操
2楼-- · 2020-05-19 02:41

I resolved this problem by change application.properties of

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

to

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

Hope it help

查看更多
smile是对你的礼貌
3楼-- · 2020-05-19 02:42

If you're using Hibernate then change in your "hibernate.cfg.xml" the following:

<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

To:

<property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>

That should do :)

查看更多
三岁会撩人
4楼-- · 2020-05-19 02:43

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>
查看更多
够拽才男人
5楼-- · 2020-05-19 02:44

I'm using Eclipse and defined MySql connection pool in META_INF/context.xml. Part of its content is:

<Context>
  <Resource name="..." 
    driverClassName="com.mysql.jdbc.Driver" 
    ... />
</Context>

When I changed the line starting with "driverClassName" as follows, problem is gone.

driverClassName="com.mysql.cj.jdbc.Driver"
查看更多
该账号已被封号
6楼-- · 2020-05-19 02:46

in my experience. I was using jsp for web. at that time I use mysql 5 and mysql connecter jar 8. So due to the version problem I face this kind of problem. I solve by replace the mysql connector jar file the exact version mysql.

查看更多
劫难
7楼-- · 2020-05-19 02:49
        // The newInstance() call is a work around for some
        // broken Java implementations
        Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
查看更多
登录 后发表回答