'Java Eclipse IDE [mySQL Driver cannot be reached] [duplicate]

I have this problem where I tried to connect to mySQL driver by using this code below.I set the code that if I failed to connect to mySQL Driver, a popup will appear and say mySQL Driver cannot be reached and it does appear. I have imported mysql-connector-java-8.0.29.jar in `Referenced Libraries.

package belajarjavaGUI;


    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.sql.Connection;
    import java.sql.Statement;


    public class trial extends JFrame implements ActionListener {
                
                Connection con;
                Statement stmt;
                JLabel          lbluser, lblpass;
                JTextField      txtuser;
                JPasswordField  txtpass;
                JButton         btnLogin;
                
                public trial() 
                {
                    settingFrame();
                    settingInterface();
                }
                
                void settingFrame()
                {
                    setLayout(null);
                    setSize(280,200);
                    setTitle("Unit Latihan Industri");
                    setVisible(true);
                    setLocationRelativeTo(null);
                    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                     
                }

                void settingInterface()
                {
                    
                    btnLogin = new JButton("Login");
                    btnLogin.setBounds(70, 100, 100, 50);
                    add(btnLogin);
                    btnLogin.addActionListener(this);
                }
                
                public static void main(String[] args) 
                {
                    new trial();

                }

                public void actionPerformed(ActionEvent e) 
                {
                    if(e.getSource() == btnLogin) {
                
                        //1.load driver
                        try {
                            Class.forName("com.mysql.jdbc.Driver");
                            
                        } catch (ClassNotFoundException e1) {
                            
                            JOptionPane.showMessageDialog(null,"mySQL Driver cannot be reached");
                        }
                    }
                }
    }


Solution 1:[1]

Try with Class.forName("com.mysql.cj.jdbc.Driver");

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mark Rotteveel