Bonjour ,

Je travail sur une application web , j'essaie d'inserer des données dans une table avec une clé auto incrementé et j'utilise une requete preparé mais il me donne toujours a chaque tentative d'ajout cette erreur.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' at line 1
voilà le code que j'utilise :
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
 
public static int AjoutCandidat(CompteCandidat comptecandidat) {
 
		int resultat = 0;
		PreparedStatement prpStmt = null;
 
		try {
 
			Connection con = (Connection) ConnectionManager.getConnection();
 
			String sql = "insert into comptecandidat (nom,prenom,adresse,ville,dateNaissance,telephonePersonnel,adresseMail,experience,niveauEtudes,login,password) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
			prpStmt = (PreparedStatement) con.clientPrepareStatement(sql,
					PreparedStatement.RETURN_GENERATED_KEYS);
			prpStmt.setString(1, comptecandidat.getNom());
			prpStmt.setString(2, comptecandidat.getPrenom());
			prpStmt.setString(2, comptecandidat.getAdresse());
			prpStmt.setString(4, comptecandidat.getVille());
			prpStmt.setString(5, comptecandidat.getDateNaissance());
			prpStmt.setString(6, comptecandidat.getTelephonePersonnel());
			prpStmt.setString(7, comptecandidat.getAdresseMail());
			prpStmt.setString(8, comptecandidat.getExperience());
			prpStmt.setString(9, comptecandidat.getNiveauEtudes());
			prpStmt.setString(10, comptecandidat.getLogin());
			prpStmt.setString(11, comptecandidat.getPassword());
			resultat = prpStmt.executeUpdate(sql);
			prpStmt.close();
			con.close();
 
		} catch (SQLException e) {
			e.printStackTrace();
		}
 
		catch (Exception e) {
			e.printStackTrace();
		}
		return resultat;
	}
}