1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| private void validerActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String id = identifiant.getText();
if(id.equals(""))
{
JOptionPane.showMessageDialog(null, "Vous devez saisir un identifiant valide dans le champ prévu à cet effet", "Identifiant inconnu", JOptionPane.ERROR_MESSAGE);
}
else
{
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection connec = DriverManager.getConnection("jdbc:mysql://localhost/jerale", "root", "");
String commande = "SELECT * FROM membre WHERE pseudo = '" + id + "'";
System.out.println(commande);
Statement stmt = connec.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet res = stmt.executeQuery(commande);
System.out.println("Nous sommes avant la boucle");
while(res.next())
{
System.out.println("Nous sommes dans la boucle");
String pseudo = res.getString(2);
System.out.println(pseudo);
}
}
catch (SQLException ex)
{
System.out.println("Erreur SQL");
}
catch (ClassNotFoundException ex)
{
System.out.println("ClassNotFoundException");
}
}
} |
Partager