我尝试在处理后从同一个表中另一列的连续更新表的列。
我使用Java进行处理,我只是设法为我的表的第一行执行此任务。
我不知道为什么我无法浏览"结果集"。我该如何解决这个问题?
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);
//treatement
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 += ", ";
//updating my 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();
}
//for pointing on the next row of "resultset"
i++;
}