0

I've created a JFrame on eclipse for authetification by a username and a password which i recover them through mysql workbench database, and i have imported the library "jar" of mysql connector java and build it on the project. the code is the one given bellow:

pnlBtnlogin.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
                String pseudo = txtUsername.getText();
                String mdp= pwd.getText();
        
                try {
                    
                    Class.forName("com.mysql.cj.jdbc.Driver");
                    Connection conn =(Connection)DriverManager.getConnection("jdbc:mysql//localhost:3306/utilisateurs","root","Mrayhana123");
                    Statement stm = conn.createStatement();
                    String sql="select * from etudiant where username='"+pseudo+"' and pwd='"+mdp+"'";
                    ResultSet result = stm.executeQuery(sql);
                    if(result.next()) {
                        lblLoginMessage.setText("vous êtes connecté");
                        lblLoginMessage.setForeground(Color.GREEN);
                    }
                    else {
                        lblLoginMessage.setText("Pseudo ou mot de passe incorrect !");
                        lblLoginMessage.setForeground(Color.RED);
                    }
                    
                } catch(Exception e1){
                    e1.printStackTrace();               
                    }

**And the result : **

java.sql.SQLException: No suitable driver found for jdbc:mysql//localhost:3306/utilisateurs at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228) at ProjetSra.FrameLogin$4.mouseClicked(FrameLogin.java:161) at java.desktop/java.awt.Component.processMouseEvent(Component.java:6638) at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342) at java.desktop/java.awt.Component.processEvent(Component.java:6400) at java.desktop/java.awt.Container.processEvent(Container.java:2263) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843) at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918) at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4556) at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Thank you for helpin me.

infomr
  • 3
  • 5

0 Answers0