Bonjour,
Dans mon programme je souhaite que dès dans la colonne "pseudo" en enregistrement portant la valeur "xavier" est trouvé ce dernier soit remplacé par "pascal".
Mon code me renvoi l'erreur suivante :
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 public class PremJDBC { public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); Connection connec = DriverManager.getConnection("jdbc:mysql://localhost/jerale", "root", ""); try { String requete = "SELECT pseudo FROM membre"; Statement stmt = connec.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet res = stmt.executeQuery(requete); String pseudo; while(res.next()) { pseudo = res.getString(1); System.out.println(pseudo); if(pseudo.equals("xavier")) { res.updateString(1, "pascal"); res.updateRow(); } } } catch(Exception e) { e.printStackTrace(); } finally { connec.close(); System.out.println("Connection fermée : " + connec.isClosed()); } } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part com.mysql.jdbc.NotUpdatable: Result Set not updatable (references no primary keys).This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.
Quelqu'un pourrait m'aider ?
Merci d'avance
Partager