Bonjour,
J'ai comme projet de fin d'études une application de gestion des portefeuilles clients d'une entreprise. Pour commencer, je me suis lancé dans l'interface d'authentification. Le problème est que je n'arrive pas a comprendre pourquoi le login et le mot de passe que j'insère sont toujours considérés comme correctes et ils ne sont pas comparé avec les données de la base. Ensuite, je voudrais savoir comment ne pas afficher les caractères du mot de passe lors de l'écriture.

Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package ma.lydec.portefeuille.connexion;
 
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
 
 
/*
 * Connexion.java
 
 */
import java.sql.*;
 
/**
 *
 * @author 2MBA
 */
public class Connexion extends javax.swing.JFrame {
 
    /** Creates new form Connexion */
    public Connexion() {
        initComponents();
    }
 
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {
 
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        textlogin = new javax.swing.JTextField();
        textmdp = new javax.swing.JTextField();
        btnseconnecter = new javax.swing.JButton();
 
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
 
        jLabel1.setText("Connexion");
 
        jLabel2.setText("Login");
 
        jLabel3.setText("Mot de Passe");
 
        textlogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textloginActionPerformed(evt);
            }
        });
 
        textmdp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textmdpActionPerformed(evt);
            }
        });
 
        btnseconnecter.setText("Se Connecter");
        btnseconnecter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnseconnecterActionPerformed(evt);
            }
        });
 
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(52, 52, 52)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2))
                        .addGap(74, 74, 74)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(textmdp, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textlogin, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(100, 100, 100)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnseconnecter)
                            .addComponent(jLabel1))))
                .addContainerGap(117, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jLabel1)
                .addGap(37, 37, 37)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(textlogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(80, 80, 80)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(textmdp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(60, 60, 60)
                .addComponent(btnseconnecter)
                .addContainerGap(52, Short.MAX_VALUE))
        );
 
        pack();
    }// </editor-fold>                        
 
    private void textloginActionPerformed(java.awt.event.ActionEvent evt) {                                          
    }                                         
 
    private void textmdpActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
    } 
private void btnseconnecterActionPerformed(java.awt.event.ActionEvent evt) {                                               
  PreparedStatement test = null;
  String login = textlogin.getText();
  ResultSet rs = null;
  String url = "jdbc:mysql://localhost:3306/portefeuille";
  String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
  String user = "root";
  String password = "";
 
    try {
 
  Class.forName(driver);
  Connection connection = (Connection) DriverManager.getConnection(url,user, password);
  String sql = "SELECT * FROM user WHERE login = ?";
  test = connection.prepareStatement(sql);
  test.setString(1, login ); 
  rs = test.executeQuery();
 if (rs == null)
{ System.out.println ("erreur");}
else
{ System.out.println ("correct");}
 
  connection.close();
}
    catch (ClassNotFoundException cnfe) {
  System.err.println(cnfe);
}
  catch (SQLException sqle) {
  System.err.println(sqle);
}
}
 
public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable(){
        public void run()
        {
            new Connexion().setVisible(true);
        }});
}                     
private javax.swing.JButton btnseconnecter;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JTextField textlogin;
private javax.swing.JTextField textmdp;
// End of variables declaration                   
}
Merci d'avance pour votre aide.