java与Mysql连接问题调试出现异常

数据库信息能正确访问,但是编译结果出现java.lang.ClassNotFoundException


```![图片说明](https://img-ask.csdn.net/upload/202007/27/1595857685_608579.png)![图片说明](https://img-ask.csdn.net/upload/202007/27/1595857697_702981.png)


package op;
import java.sql.*;
public class DB {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        try {
            Class.forName("com.mysql.jc.jdbc.Driver");
            System.out.print("Register success");
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            System.out.print("Register failed");
        }
        String url="jdbc:mysql://localhost/test?useSSL=false&serverTimezone=UTC";
        Connection connection=null;

        try {
            connection=DriverManager.getConnection(url,"root","123.com");

            Statement statement=connection.createStatement();
            System.out.println("created success");

            ResultSet resultSet=statement.executeQuery("select * from pool");

            while(resultSet.next()) {
                System.out.println(resultSet.getString(1)+","+resultSet.getInt(2));
            }
            resultSet.close();
            statement.close();
        } catch (SQLException e) {
            // TODO: handle exception
            e.printStackTrace();
        }finally {
            try {
                if(null != connection) {
                    connection.close();
                }
            } catch (SQLException e2) {
                // TODO: handle exception
                e2.printStackTrace();
            }
        }

    }

}

图片挂了, 一般是 MySQL 的 jar 包不在 CLASSPATH 里, 推荐使用 maven 创建工程

看你的报错信息,应该还是你的jdbc驱动的jar包没有配置队,检查下。

jdbc的jar 降级试试