ingtechnologie
-
Modifié par jordane45 le 20/02/2014 à 13:43
DevLama
Messages postés356Date d'inscriptionmercredi 13 avril 2011StatutMembreDernière intervention18 novembre 2021
-
20 févr. 2014 à 17:11
Bonjour, j'ai un probleme avec mon bouton authentification j'ai besouin de votre aide merci beaucoup
private void BntvaliderActionPerformed(java.awt.event.ActionEvent evt) {
PreparedStatement St = null;
String login = Txtlogin.getText();
String password = TxtPassword.getText();
ResultSet Rs = null;
St=null;
try{///chaine de conection avec BD Mysql
Class.forName("com.mysql.jdbc.Driver");
Connection cnx = DriverManager.getConnection("Jdbc:Odbc:TestBD", "root", "");
String sql = "SELECT login FROM UTILISATEUR WHERE login= ? AND password = ?";
St = (PreparedStatement) cnx.prepareStatement(sql);
St.setString(1, login);
St.setString(2, password);
Rs = St.executeQuery();
if (!Rs.next()) {
System.out.println("Echec de la connexion");
}
else {
setVisible(false);// fermer la frame courante auth
new MenuPrincipale().setVisible(true);// ouvre la frame accueil
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(null, "Authentification Echouér" +e.getMessage());
}
NB:voicie le Message d'erreur qui m'affiche -:Authentificationsun.jdbc.odbc.JdbcOdbcPreparedStatement cannot be cast to com.mysql.jdbc.PreparedStatement--