Interface login

chahde14 Messages postés 12 Date d'inscription samedi 29 janvier 2011 Statut Membre Dernière intervention 7 mars 2020 - Modifié le 25 févr. 2020 à 22:00
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 - 2 mars 2020 à 12:57
Bonjour,
se code ne marche pas a cause de preparestatement
st=maConnexion.getConnection().prepareStatement(query);
mais je sais pas comment faire
si quelqu'un peut m'aidée meci

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        PreparedStatement st;
        ResultSet rs;
        String username = txtuser.getText();
        String password = String.valueOf(Password.getPassword());
        
          String query = "SELECT * FROM `tablelogin` WHERE `username` = ? AND `password` = ?";
          
        
     try {
         st=maConnexion.getConnection().prepareStatement(query);
         st.setString(1, username);
         st.setString(2, password);
         rs=st.executeQuery();
         if (rs.next())
         {
         //show a new form
             MonApplication form=new MonApplication();
             form.setVisible(true);
             form.pack();
             form.setLocationRelativeTo(null);
             //close the current form login
             this.dispose();
          }else{
         //error message
         JOptionPane.showMessageDialog(null, "Invalide username / ","login error",2);
         }
     } catch (SQLException ex) {
         Logger.getLogger(login.class.getName()).log(Level.SEVERE, null, ex);
     }
        

 
    }                   
A voir également:

1 réponse

Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
2 mars 2020 à 12:57
Salut,

Tu as quoi comme erreur ?
0
Rejoignez-nous