Bonjour,
Pour m'entrainer j'essaye de modifier la colonne d'une table.
J'utilise un UPDATE ça fonctionne bien dans mon fichier access, mais les changements ne s'affichent pas dans ma console avec mon System.out.println("");
Voici mon code :
Si vous avez une idée merci beaucoup
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 static String dataSourceName = "BaseDeDonnee" + ""; static String dbURL = "jdbc:odbc:" + dataSourceName; public static void main(String[] args) throws SQLException, ClassNotFoundException { try { //***Connexion***** Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection(dbURL, "",""); System.out.println("it Works !"); //***************** Statement s = con.createStatement(); ResultSet rs = s.executeQuery("SELECT * FROM Images"); ResultSetMetaData resultMeta = rs.getMetaData(); //***Affichage*** while(rs.next()){ System.out.println(rs.getString("file_path") + " | " + rs.getString("color_percentage") + " | " + rs.getString("centered")+ " | " + rs.getString("level")); } System.out.println("************************"); //Modification s = con.createStatement(); int statut = s.executeUpdate("UPDATE Images set edge_complexity = 149"); //Affchage une seconde fois pour voir le changement while(rs.next()){ System.out.println(rs.getString("file_path") + " | " + rs.getString("color_percentage") + " | " + rs.getString("centered")+ " | " + rs.getString("level")); } //***Deconnexion*** rs.close(); s.close(); con.close(); } catch (Exception err) { System.out.println( "Error: " + err ); } }
Partager