Bonjour,

Je voudrais faire une insertion dans une table sql à partir d'un formulaire voici le code qu j'ai écrit mais l'insertion n'est pas effectué.
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
@Override
	public void actionPerformed(ActionEvent evt) {
		Connection laConnection;
		if (evt.getSource()==b2){
			System.exit(0);
		}
		if (evt.getSource()==b1){
			try
			{ 
			Class.forName("com.mysql.jdbc.Driver");
 
			laConnection =  (Connection) DriverManager.getConnection("jdbc:mysql://localhost/application?useSSL=false","boutheina","30071986"); 
 
			String sql = "INSERT INTO client (nom, prenom, adresse,login,psw) VALUES(?,?,?,?,?)"; 
 
			try( PreparedStatement preparedStatement = (PreparedStatement) laConnection.prepareStatement(sql) ) { //préparation de la requête 
 
			    preparedStatement.setObject(1, text1); //on assigne le login au premier paramètre 
			    preparedStatement.setObject(2, text2);
			    preparedStatement.setObject(3, text3);
			    preparedStatement.setObject(4, text4);
			    preparedStatement.setObject(5, text5); 
 
 
			    if(preparedStatement.executeUpdate()!=1){
			    	JOptionPane.showMessageDialog(null, "An error appears in the inscription", 
                            "Error Message",
                            JOptionPane.ERROR_MESSAGE);}
			    else{JOptionPane.showMessageDialog(null, "The inscription is done successfully", 
                        "Information Message",
                        JOptionPane.INFORMATION_MESSAGE);}
 
 
 
 
			}
 
			}
 
			catch
			(Exception e)
			{
			            System.out.print("impossible de se connecter à la base");
 
			} 
	 }
		}
		// TODO Auto-generated method stub
 
	}