I executed a code that is used to display the specified information from a content of a field in a column "update_action" a table "incident" a database "base_rapport_tt" on WampServer. and in my table, I added another column in which I will store the displayed information. My goal is to display the result of the whole column and store it in the new column order.
try
{
String Sql="Select Update_Action from incident where id_incident ='"+jTextField3.getText()+"' and Status like 'Closed'";
con = getConnection("jdbc:mysql://localhost:3306/base_rapport_tt","root","");
stmt=con.createStatement();
rs=stmt.executeQuery(Sql);
while(rs.next()) {
str=rs.getString("update_Action");
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+=", ";
}
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(this,e);
}
I tried with this code:
try
{
String Sql="Select Update_Action,id_incident from incident
where Status like 'Closed'";
con = getConnection("jdbc:mysql://localhost:3306/base_rapport_tt","root","");
stmt=con.createStatement();
rs=stmt.executeQuery(Sql);
while(rs.next()) {
str=rs.getString("update_Action");
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+=", ";
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/base_rapport_tt", "root", "");
String query = "update incident set intervenants = ? where id_incident like '%'";
java.sql.PreparedStatement preparedStmt = conn.prepareStatement(query);
preparedStmt.setString(1,nom);
preparedStmt.executeUpdate();
conn.close();
}
}
}
catch (Exception e)
{
//JOptionPane.showMessageDialog(this,e);
}
the result of the first column of the recipient field is well. But the problem is that the other fields is the result of the former.
thanks.