chahde14
Messages postés12Date d'inscriptionsamedi 29 janvier 2011StatutMembreDernière intervention 7 mars 2020
-
Modifié le 25 févr. 2020 à 22:00
Twinuts
Messages postés5374Date d'inscriptiondimanche 4 mai 2003StatutModérateurDernière intervention 3 mars 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);
}
}