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

标题问题描述:

本人在学习尚硅谷的JDBC课程时,在获取数据库连接时,出现了问题
Loading classcom.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.
出现此问题的代码如下所示,JDK版本是Azul Zulu version 17.0.1,MySQL版本是8.0.27

package com.connectionTest;

import org.junit.Test;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.util.Properties;

public class Connection_test {
    @Test
    public void testConnection1() throws SQLException {
        /*
        jdbc:mysql:协议
        localhost:ip地址
        3306:默认端口号
        test:test数据库
         */
        Driver driver = new com.mysql.jdbc.Driver();
        String url = "jdbc:mysql://localhost:3306/atguigudb";
        Properties info = new Properties();
        info.setProperty("user", "root");
        info.setProperty("password","");
        Connection conn = driver.connect(url, info);
        System.out.println(conn);
    }
}

解决办法

刚看到问题会比较懵,怀疑自己的操作是否跟康老师不一样,hh。其实是因为com.mysql.jdbc.Driver被替换成了com.mysql.cj.jdbc.Driver

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值