Bonjour à Tous,

Merci à tous pour votre aide

Voici tout d'abord mon erreur

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at medisoft.PatientDB.AddPatient(PatientDB.java:39)
at medisoft.Ajouter.jButton3_actionPerformed(Ajouter.java:247)
at medisoft.Ajouter_jButton3_actionAdapter.actionPerformed(Ajouter.java:290)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Et Voici Les classe d'ou vient l'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
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
package medisoft;
import java.awt.BorderLayout;
 
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Font;
import javax.swing.SwingConstants;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JList;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import java.awt.Color;
import javax.swing.BorderFactory;
import java.awt.SystemColor;
import javax.swing.JOptionPane;
import java.awt.event.KeyEvent;
import java.awt.event.KeyAdapter;
 
 
public class Ajouter extends JFrame {
    public Ajouter() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
 
    private void jbInit() throws Exception {
        this.getContentPane().setBackground(SystemColor.inactiveCaption);
        this.setCursor(null);
        this.setJMenuBar(null);
        this.setResizable(false);
        this.setTitle("Gestionaire MEDISOFT");
        this.setVisible(true);
        this.getContentPane().setLayout(null);
        this.setBounds(200,100,630,520);
        jLabel1.setFont(new java.awt.Font("Tahoma", Font.BOLD, 15));
        jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel1.setText("Nouveau Patient");
        jLabel1.setBounds(new Rectangle(0, 12, 630, 29));
        jLabel2.setText("Nom & Prénom");
        jLabel2.setBounds(new Rectangle(62, 72, 99, 14));
        jLabel3.setText("CIN");
        jLabel3.setBounds(new Rectangle(62, 108, 50, 14));
        jLabel4.setText("Sexe");
        jLabel4.setBounds(new Rectangle(62, 141, 64, 14));
        jLabel5.setText("Adresse");
        jLabel5.setBounds(new Rectangle(62, 179, 71, 14));
        jLabel6.setText("Téléphone");
        jLabel6.setBounds(new Rectangle(62, 211, 67, 14));
        jLabel7.setText("Médecin Traitant");
        jLabel7.setBounds(new Rectangle(62, 243, 100, 14));
        jLabel8.setText("Mutualiste");
        jLabel8.setBounds(new Rectangle(62, 277, 96, 14));
        jLabel9.setText("Antécédants Médicaux");
        jLabel9.setBounds(new Rectangle(62, 308, 131, 14));
        jTextArea1.setBorder(BorderFactory.createEtchedBorder());
        jTextArea1.setBounds(new Rectangle(197, 308, 205, 80));
        jTextField2.setBounds(new Rectangle(197, 243, 205, 19));
        jTextField3.setBounds(new Rectangle(197, 211, 205, 19));
        jTextField4.setBounds(new Rectangle(197, 179, 205, 19));
        jRadioButton1.setBackground(SystemColor.inactiveCaption);
        jRadioButton1.setSelected(true);
        jRadioButton1.setText("Masculin");
        jRadioButton1.setBounds(new Rectangle(196, 139, 94, 21));
        jRadioButton1.addActionListener(new Ajouter_jRadioButton1_actionAdapter(this));
        jRadioButton2.setBackground(SystemColor.inactiveCaption);
        jRadioButton2.setText("Féminin");
        jRadioButton2.setBounds(new Rectangle(292, 138, 93, 23));
        jLabel13.setFont(new java.awt.Font("Tahoma", Font.BOLD | Font.ITALIC,
                                           11));
        jLabel13.setForeground(Color.darkGray);
        jLabel13.setText("Seules les Lettres sont Acceptées");
        jLabel13.setBounds(new Rectangle(412, 243, 205, 19));
        jLabel11.setFont(new java.awt.Font("Tahoma", Font.BOLD | Font.ITALIC,
                                           11));
        jLabel11.setForeground(Color.darkGray);
        jLabel11.setText("Seules les Lettres sont Acceptées");
        jLabel11.setBounds(new Rectangle(412, 72, 205, 19));
        jRadioButton3.setBackground(SystemColor.inactiveCaption);
        jRadioButton3.setSelected(true);
        jRadioButton3.setText("Oui");
        jRadioButton3.setBounds(new Rectangle(200, 277, 93, 23));
        jRadioButton4.setBackground(SystemColor.inactiveCaption);
        jRadioButton4.setText("Non");
        jRadioButton4.setBounds(new Rectangle(292, 277, 93, 23));
        jLabel12.setFont(new java.awt.Font("Tahoma", Font.BOLD | Font.ITALIC,
                                           11));
        jLabel12.setForeground(Color.darkGray);
        jLabel12.setText("Seuls les Chiffres sont Acceptés");
        jLabel12.setBounds(new Rectangle(412, 211, 205, 19));
        radioGroup.add(jRadioButton1);
        radioGroup.add(jRadioButton2);
        radioGroup2.add(jRadioButton3);
        radioGroup2.add(jRadioButton4);
        jTextField5.setBounds(new Rectangle(197, 108, 205, 19));
        jTextField6.setBounds(new Rectangle(197, 72, 205, 19));
        jButton1.setBounds(new Rectangle(93, 423, 130, 23));
        jButton1.setToolTipText("Retour au Menu Principal");
        jButton1.setText("Menu Principal");
        jButton1.addActionListener(new Ajouter_jButton1_actionAdapter(this));
        jButton2.setBounds(new Rectangle(467, 423, 73, 23));
        jButton2.setToolTipText("Retour à la Gestion des Patients");
        jButton2.setText("Retour");
        jButton2.addActionListener(new Ajouter_jButton2_actionAdapter(this));
        jButton3.setBounds(new Rectangle(280, 423, 106, 23));
        jButton3.setToolTipText("Enregistrer le Patient");
        jButton3.setText("Enregistrer");
        jButton3.addActionListener(new Ajouter_jButton3_actionAdapter(this));
        this.getContentPane().add(jLabel1);
        this.getContentPane().add(jLabel2);
        this.getContentPane().add(jLabel3);
        this.getContentPane().add(jLabel5);
        this.getContentPane().add(jLabel6);
        this.getContentPane().add(jLabel7);
        this.getContentPane().add(jLabel8);
        this.getContentPane().add(jLabel4);
        this.getContentPane().add(jLabel9);
        this.getContentPane().add(jTextArea1);
        this.getContentPane().add(jTextField2);
        this.getContentPane().add(jTextField3);
        this.getContentPane().add(jTextField4);
        this.getContentPane().add(jRadioButton2);
        this.getContentPane().add(jTextField5);
        this.getContentPane().add(jTextField6);
        this.getContentPane().add(jLabel11);
        this.getContentPane().add(jLabel13);
        this.getContentPane().add(jRadioButton3);
        this.getContentPane().add(jRadioButton4);
        this.getContentPane().add(jLabel12);
        this.getContentPane().add(jRadioButton1);
        this.getContentPane().add(jButton3);
        this.getContentPane().add(jButton1);
        this.getContentPane().add(jButton2);
        jTextField3.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(KeyEvent source) {
                int k = source.getKeyChar();
                if (k == 46)
                    source.setKeyChar((char) KeyEvent.VK_CLEAR);
                else if ((k > 47 && k < 58) ||
                         (k == 8 || k == KeyEvent.VK_PERIOD)) {} else {
                    source.setKeyChar((char) KeyEvent.VK_CLEAR);
                }
            }
        });
        jTextField6.addKeyListener(new KeyAdapter() {
            public void keyTyped(KeyEvent source) {
                int k = source.getKeyChar();
                if (k == 46)
                    source.setKeyChar((char) KeyEvent.VK_CLEAR);
                else if ((k > 64 && k < 91) || (k > 96 && k < 123) ||
                         (k == 8 || k == KeyEvent.VK_PERIOD)) {} else {
                    source.setKeyChar((char) KeyEvent.VK_CLEAR);
                }
            }
        });
        jTextField2.addKeyListener(new KeyAdapter() {
            public void keyTyped(KeyEvent source) {
                int k = source.getKeyChar();
                if (k == 46)
                    source.setKeyChar((char) KeyEvent.VK_CLEAR);
                else if ((k > 64 && k < 91) || (k > 96 && k < 123) ||
                         (k == 8 || k == KeyEvent.VK_PERIOD)) {} else {
                    source.setKeyChar((char) KeyEvent.VK_CLEAR);
                }
            }
        });
  }
    PatientDB sdb =  new PatientDB();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JLabel jLabel7 = new JLabel();
    JLabel jLabel8 = new JLabel();
    JLabel jLabel9 = new JLabel();
    JTextArea jTextArea1 = new JTextArea();
    JTextField jTextField2 = new JTextField();
    JTextField jTextField3 = new JTextField();
    JTextField jTextField4 = new JTextField();
    JRadioButton jRadioButton1 = new JRadioButton();
    JRadioButton jRadioButton2 = new JRadioButton();
    ButtonGroup radioGroup = new ButtonGroup();
    ButtonGroup radioGroup2 = new ButtonGroup();
    JTextField jTextField5 = new JTextField();
    JTextField jTextField6 = new JTextField();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JButton jButton3 = new JButton();
    JLabel jLabel13 = new JLabel();
    JLabel jLabel11 = new JLabel();
    JRadioButton jRadioButton3 = new JRadioButton();
    JRadioButton jRadioButton4 = new JRadioButton();
    JLabel jLabel12 = new JLabel();
    public void jRadioButton1_actionPerformed(ActionEvent actionEvent) {
 
    }
 
    public void jButton2_actionPerformed(ActionEvent actionEvent) {
        this.setVisible(false);
        General layout = new General();
        layout.setVisible(true);
    }
 
    public void jButton3_actionPerformed(ActionEvent actionEvent) {
        String gender, mutualiste;
        gender = "Masculin";
        mutualiste = "Non";
       if (jTextArea1.getText().compareTo("") == 0 ||
            jTextField2.getText().compareTo("") == 0 ||
            jTextField3.getText().compareTo("") == 0 ||
            jTextField4.getText().compareTo("") == 0 ||
            jTextField5.getText().compareTo("") == 0 ||
            jTextField6.getText().compareTo("") == 0) {
          String ms = "Veuillez remplir tous les champs requis. SVP!!";
          JOptionPane.showMessageDialog(null, ms);
        }
        else {
              if(jRadioButton1.isSelected())
                  gender="Masculin";
              else
                  gender="Féminin";
              if(jRadioButton3.isSelected())
                  mutualiste = "Oui";
              else
                  mutualiste = "Non";
 
              sdb.AddPatient(jTextField6.getText().toString(), jTextField5.getText().toString(),
                             gender, jTextField4.getText().toString(), jTextField3.getText().toString(),
                             jTextField2.getText().toString(), mutualiste, jTextArea1.getText().toString());
              String message = "Le produit a été ajouté à la base de données.";
              JOptionPane.showMessageDialog(null, message);
              sdb.CloseDB();
        }
 
        this.jTextArea1.setText(null);
        this.jTextField3.setText(null);
        this.jTextField4.setText(null);
        this.jTextField6.setText(null);
        this.jTextField5.setText(null);
        this.jTextField2.setText(null);
    }
 
    public void jButton1_actionPerformed(ActionEvent actionEvent) {
        this.setVisible(false);
        Home layout2 = new Home();
        layout2.setVisible(true);
    }
}
 
 
class Ajouter_jButton1_actionAdapter implements ActionListener {
    private Ajouter adaptee;
    Ajouter_jButton1_actionAdapter(Ajouter adaptee) {
        this.adaptee = adaptee;
    }
 
    public void actionPerformed(ActionEvent actionEvent) {
        adaptee.jButton1_actionPerformed(actionEvent);
    }
}
 
 
class Ajouter_jButton3_actionAdapter implements ActionListener {
    private Ajouter adaptee;
    Ajouter_jButton3_actionAdapter(Ajouter adaptee) {
        this.adaptee = adaptee;
    }
 
    public void actionPerformed(ActionEvent actionEvent) {
        adaptee.jButton3_actionPerformed(actionEvent);
    }
}
 
 
class Ajouter_jButton2_actionAdapter implements ActionListener {
    private Ajouter adaptee;
    Ajouter_jButton2_actionAdapter(Ajouter adaptee) {
        this.adaptee = adaptee;
    }
 
    public void actionPerformed(ActionEvent actionEvent) {
        adaptee.jButton2_actionPerformed(actionEvent);
    }
}
 
 
class Ajouter_jRadioButton1_actionAdapter implements ActionListener {
    private Ajouter adaptee;
    Ajouter_jRadioButton1_actionAdapter(Ajouter adaptee) {
        this.adaptee = adaptee;
    }
 
    public void actionPerformed(ActionEvent actionEvent) {
        adaptee.jRadioButton1_actionPerformed(actionEvent);
    }
}
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
package medisoft;
 
 
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.ResultSetMetaData;
import javax.swing.JOptionPane;
 
public class PatientDB {
 
  public Connection myCon=null;
 
  public PatientDB() {
 
     String DRIVER = "com.borland.datastore.jdbc.DataStoreDriver";
     String URL = "jdbc:borland:dslocal:";
     String FILE = "database/PATIENT.jds";
 
     try {
       Class.forName(DRIVER);
       myCon = DriverManager.getConnection(URL + FILE, "Mehdi", " ");
     }
     catch (Exception e) {
 
       System.out.println(e);
     }
  }
 
  public boolean AddPatient(String name, String cin, String gender,
                          String address, String phone, String traitant, String mutualiste,
                          String antecedants) {
 
    ResultSet r = null;
 
    try {
      Statement s = myCon.createStatement();
      r = s.executeQuery("Select * from patient where CIN='" + cin +"'");
 
      if ( (r.next())) {
        String message = "Le patient existe déjà dans la base données, Veuillez changer le numéro de la carte nationale";
        JOptionPane.showMessageDialog(null, message);
        return false;
      }
      else {
        try {
          this.myCon.createStatement().execute("insert into PATIENT values ('" + name + "','" + cin + "','" + gender + "','" +
                                               address + "','" + phone + "','" + traitant + "','" + mutualiste + "','" + antecedants +"')");
        }
        catch (SQLException ex) {
          return false;
        }
        return true;
      }
    }
    catch (SQLException ex) {
      System.err.println("" + ex);
    }
    return false;
 }
 
  public ResultSet Search(String name) {
    ResultSet r=null;
    try {
 
      Statement s = this.myCon.createStatement();
      r = s.executeQuery("Select * from PATIENT where NOM= '" + name + "'");
    }
    catch (SQLException ex) {
      return null;
    }
 return r;
 }
 
 
    public boolean Delete_Name(String name) {
      ResultSet r = null;
 
      try {
        Statement s = this.myCon.createStatement();
        r = s.executeQuery("Select * from PATIENT where \"LAST_NAME\"='" + name +
                           "'");
        if (! (r.next())) {
          return false;
        }
        else {
          try {
            this.myCon.createStatement().execute(
                "delete from PATIENT where \"LAST_NAME\"='" + name + "'");
          }
          catch (SQLException ex) {
            return false;
          }
          return true;
 
        }
      }
      catch (SQLException ex) {
        System.err.println("" + ex);
      }
      return false;
    }
 
public  ResultSet ViewAll() {
  ResultSet r= null;
try{
    Statement s = this.myCon.createStatement();
    r = s.executeQuery("Select * from PATIENT");
     ResultSetMetaData rs = r.getMetaData();
 
  }
  catch (SQLException ex) {
 
    return null;
  }
 
return r;
}
 
    public void CloseDB() {
        try {
          this.myCon.close();
        }
        catch (SQLException ex) {
          ex.printStackTrace();
        }
    }
    private void jbInit() throws Exception {
    }
}
Je ne suis pas trop experte en Java alors je ne sais pas trop comment resoudre ce probleme

Merci beaucoup d'avance