eclipse创建登录窗口一直报错

问题遇到的现象和发生背景

在使用eclipse创建窗口时一直报错

遇到的现象和发生背景,请写出第一个错误信息

img

用代码块功能插入代码,请勿粘贴截图。 不用代码块回答率下降 50%
package denglu;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Dao {
    private String user="root";
    private String password="111111";
    private String url="jdbc:mysql://localhost:3306/gyc";
    
    private Connection conn=null;
    public Connection getConnection() {
        try {
            Class.forName(  "com.mysql.jdbc.jc.driver");
        } catch(ClassNotFoundException e) {
            e.printStackTrace();
        }
        try {
            conn=DriverManager.getConnection(url,user,password);
        }catch (SQLException e){
            e.printStackTrace();
        }
        return conn;

}
}


```java
package denglu;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;

import javax.swing.*;

public class zy  {
    private JFrame frame;
    private JTextField userTextField;
    private JPasswordField passwordField;
    private JLabel userLabel,passwordLabel;
    
    private JButton loginButton,exitButton,resetButton;
    
    private JPanel userPanel,passwordPanel,buttonPanel;
    
    public void lunchFrame()
    {
        this.frame=new JFrame("登录窗口");
        
        this.userTextField=new JTextField(12);
        this.passwordField=new JPasswordField(12);
        this.userLabel=new JLabel("用户名:");
        this.passwordLabel=new JLabel("密 码:");
        this.loginButton=new JButton("登录");
        this.resetButton=new JButton("重置");
        this .exitButton=new JButton("退出");
        
        this.exitButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
        
        this.userPanel= new JPanel();
        this.passwordPanel=new JPanel();
        this.buttonPanel=new JPanel();
        
        this.userPanel.add(this.userLabel);
        this.userPanel.add(this.userTextField);
        this.passwordPanel.add(this.passwordLabel);
        this.passwordPanel.add(this.passwordField);
        this.buttonPanel.add(this.loginButton);
        this.buttonPanel.add(this.resetButton);
        this.buttonPanel.add(this.exitButton);
        
        GridLayout gridLayout=new GridLayout(0,1);
        frame.setLayout(gridLayout);
        
        frame.add(this.userPanel);
        frame.add(this.passwordPanel);
        frame.add(this.buttonPanel);
        
        frame.setSize(280,180);
        frame.setVisible(true);
        frame.setResizable(false);
        frame.setLocationRelativeTo(null);
        
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        Monitor monitor=new Monitor();
        this.loginButton.addActionListener(monitor);
        
        Monitor2 monitor2=new Monitor2();
        this.resetButton.addActionListener(monitor2);
                
    }
    
    public static void main(String[] args) {
        zy  window=new zy ();
        window.lunchFrame();
    }
     
    class Monitor implements ActionListener
    {
        private Connection conn=null;
        private PreparedStatement preparedStatement=null;
        private ResultSet resultSet=null;
        
        @Override
        public void actionPerformed(ActionEvent e) {
            //TODO Auto-generated method stub
            String name=userTextField.getText();
            char[] ch=passwordField.getPassword();
            String password=new String(ch);
            
            conn=new Dao().getConnection();
            String sql="select * from user where user=? and password=?";
            
            try {
                preparedStatement=conn.prepareStatement(sql);
                preparedStatement.setString(1,name);
                preparedStatement.setString(2,password);
                
                resultSet=preparedStatement.executeQuery();
                
                if(resultSet.next())
                {
                    JOptionPane.showMessageDialog(null, "欢迎使用本系统");
                }
                else
                {
                    JOptionPane.showMessageDialog(null,"用户名或密码错误,请重新登录!");
                }
            }catch(SQLException e1) {
                //TODO Auto-generated catch block
                e1.printStackTrace();
            }finally
            {
                if(resultSet!=null)
                {
                    try {
                        resultSet.close();
                    }catch (SQLException e1) {
                        //TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                }
                if(preparedStatement!=null)
                {
                    try {
                        preparedStatement.close();
                    }catch (SQLException e1) {
                        //TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                }
                if(conn!=null)
                {
                    try {
                        conn.close();
                    }catch (SQLException e1){
                        //TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                }
            }
        }
    }
    
    class Monitor2 implements ActionListener
    {
        
        @Override
        public void actionPerformed(ActionEvent e) {
            userTextField.setText("");
            passwordField.setText("");
        }
    }
}


###### 运行结果及详细报错内容

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/653275172686111.png "#left")

###### 我的解答思路和尝试过的方法,不写自己思路的,回答率下降 60%
网上搜索是jdk版本低了,然后重新下载了也不行

缺少com.mysql.jdbc.jc.driver 这个包,这个包是mysql驱动包,你得去下载个驱动包导入项目。
但是吧,我看你工程里又有驱动包
你可以试着清除缓存,重新编译试试。如果不行,我估计你导入的包位置可能不对。

驱动名 写错了 是 com.mysql.cj.jdbc.Driver

img

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^

这里看看jar包有没有加进项目中

img