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
| //sélectionner les enregistrements à mettre à jour
String Sql="Select Update_Action,id_incident from incident where Status like 'Closed'";
con = getConnection("jdbc:mysql://localhost:3306/base_rapport","root","");
stmt=con.createStatement();
rs=stmt.executeQuery(Sql);
//éffectuer le traitement
int i=1;
while(rs.absolute(i)){
str=rs.getString(1);
nom="";
while(!"".equals(str)){
int debut=str.indexOf('(')+1;
int fin=str.indexOf(')',debut);
nom += " "+str.substring(debut,fin);
str=str.substring(fin+1,str.length());
nom+=", ";
//mettre à jours ma table
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/base_rapport", "root", "");
String query = "update incident set intervenants = ? where id_incident=?";
java.sql.PreparedStatement preparedStmt = conn.prepareStatement(query);
preparedStmt.setString(1,nom);
preparedStmt.setString(2,rs.getString(2));
preparedStmt.executeUpdate();
}
//pour passer à la ligne suivante du "resultset"
i++;
} |