Bonjour, j'ai une erreur lorsque je veux récupérer les infos sur mon serveur MySQL.

Voici mon erreur:
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
 
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at Test.Autorisation.TestJour(Autorisation.java:152)
        at Test.Autorisation.Connection(Autorisation.java:131)
        at Test.Autorisation.jButtonBadgeActionPerformed(Autorisation.java:95)
        at Test.Autorisation.access$100(Autorisation.java:7)
        at Test.Autorisation$2.actionPerformed(Autorisation.java:47)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
        at java.awt.Component.processMouseEvent(Component.java:6041)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
        at java.awt.Component.processEvent(Component.java:5806)
        at java.awt.Container.processEvent(Container.java:2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4413)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
        at java.awt.Container.dispatchEventImpl(Container.java:2102)
        at java.awt.Window.dispatchEventImpl(Window.java:2440)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Et mon code est celui-ci:
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
 
package Test;
 
import java.sql.*;
import java.lang.*;
import java.util.*;
 
public class Autorisation extends javax.swing.JFrame {
 
    boolean bool1 = false;
    boolean bool2 = false;
    String heureAutorisee = null;
    String jourAutorise = null;
    String jourFr = null;
    String tab[] = {"Samedi", "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi"};
    String jourAuto[] = {"Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi"};
    String heureAuto[] = {"0814", "0821", "0812", "0817", "0817"};
 
 
    /** Creates new form Autorisation */
    public Autorisation() {
        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.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {
 
        jTextFieldAutorisation = new javax.swing.JTextField();
        jButtonBadge = new javax.swing.JButton();
        jTextFieldNumBadge = new javax.swing.JTextField();
 
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
 
        jTextFieldAutorisation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldAutorisationActionPerformed(evt);
            }
        });
 
        jButtonBadge.setText("Passage du badge");
        jButtonBadge.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBadgeActionPerformed(evt);
            }
        });
 
        jTextFieldNumBadge.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldNumBadgeActionPerformed(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()
                .addContainerGap(47, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jTextFieldNumBadge, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(44, 44, 44))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jTextFieldAutorisation, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(94, 94, 94))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButtonBadge)
                        .addGap(130, 130, 130))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addComponent(jTextFieldNumBadge, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 78, Short.MAX_VALUE)
                .addComponent(jButtonBadge)
                .addGap(59, 59, 59)
                .addComponent(jTextFieldAutorisation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(45, 45, 45))
        );
 
        pack();
    }// </editor-fold>                        
 
    private void jTextFieldAutorisationActionPerformed(java.awt.event.ActionEvent evt) {                                                       
        // TODO add your handling code here:
}                                                      
 
    private void jButtonBadgeActionPerformed(java.awt.event.ActionEvent evt) {                                             
        // TODO add your handling code here:
        Connection();
}                                            
 
    private void jTextFieldNumBadgeActionPerformed(java.awt.event.ActionEvent evt) {                                                   
        // TODO add your handling code here:
    }                                                  
 
   public void Connection() {
        Connection conn;
        Statement stmt;
        ResultSet rs;
        String pilote = "org.gjt.mm.mysql.Driver";
        String url = new String("jdbc:mysql://10.104.100.57:3306/snecma");
 
 
        try {
            Class.forName(pilote);
 
            conn = DriverManager.getConnection(url, "root", "root");
 
            stmt = conn.createStatement();
 
            rs = stmt.executeQuery("SELECT * From utilisateur");
 
            String NumCodeBarre;
            String NumBadge = "3";
 
 
            while (bool1 == false) {
                rs.next();
                System.out.println(rs.getString(1) + " " + rs.getString(2) + " " + rs.getString(3) + " " + rs.getString(4) + "\n ");
                NumCodeBarre = rs.getString(1);
                String Nom = rs.getString(2) + " " + rs.getString(3);
 
                if (NumBadge.equals(NumCodeBarre)) {
                    jTextFieldNumBadge.setText(Nom);
                    TestJour();
                } else {
                    AccesRefuseNonPresent();
                }
            }
 
            rs.close();
            stmt.close();
            conn.close();
 
        } catch (SQLException E) {
            System.out.println("SQLException: " + E.getMessage());
            System.out.println("SQLState:     " + E.getSQLState());
            System.out.println("VendorError:  " + E.getErrorCode());
        } catch (ClassNotFoundException E) {
            E.printStackTrace();
        }
    }
 
    public void TestJour(){
        for(int i = 0; i<jourAuto.length; i++) {
            if(jourFr.equals(jourAuto[i])){
                heureAutorisee = heureAuto[i];
                jourAutorise = jourAuto[i];
            }
        }
        if(jourAutorise == null){
            JourPasPresent();
        }
        else{
            HeuresAcces();
        }    
    }
 
     public void HeuresAcces() {
        bool1 = true;
        bool2 = true;
        int heure1 = Integer.parseInt(heureAutorisee.substring(00, 02)); //correspond à 08 soit 8h
        int heure2 = Integer.parseInt(heureAutorisee.substring(02, 04)); //correspond à 17 soit 17h
        GregorianCalendar cal = new GregorianCalendar();
        int heureSys = cal.get(Calendar.HOUR_OF_DAY);
        int jourSys = cal.get(Calendar.DAY_OF_WEEK);
        jourFr = JourFrancais(jourSys);
 
        if (heureSys < heure2 && heureSys >= heure1) {
            AccesAutorise();
        } else {
            AccesRefuse();
        }
    }
 
    public String JourFrancais(int JourAnglais){
        String JourFrancais = null;
        JourFrancais = tab[JourAnglais];
 
        return JourFrancais;
    }
 
    public void AccesAutorise() {
        jTextFieldAutorisation.setText("L'accès est autorisé");
    }
 
    public void AccesRefuse() {
        jTextFieldAutorisation.setText("L'accès est refusé");
    }
 
    public void AccesRefuseNonPresent() {
        jTextFieldNumBadge.setText("L'utilisateur n'est pas présent dans la Base de données");
        jTextFieldAutorisation.setText("L'accès est refusé");
    }
 
    public void JourPasPresent(){
        jTextFieldNumBadge.setText("L'utilisateur est présent dans la Base de données");
        jTextFieldAutorisation.setText("L'accès refusé car les horaires ne sont pas valides");
    }
 
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Autorisation().setVisible(true);
            }
        });
    }
 
    // Variables declaration - do not modify                     
    private javax.swing.JButton jButtonBadge;
    private javax.swing.JTextField jTextFieldAutorisation;
    private javax.swing.JTextField jTextFieldNumBadge;
    // End of variables declaration                   
 
}
Merci d'avance.