Here is my java code:
public int function(String name)
{
int i=0;
int id=0;
try
{
String get_id="SELECT id FROM table_name JOIN tbl_2 ON tbl_name.pk_id = tbl_2.fk_name_id where active_flag=1 and updated_at <= NOW() - INTERVAL 3 MINUTE";
Statement stmt=(Statement) conn.createStatement();
ResultSet rs = stmt.executeQuery(get_id);
while (rs.next())
{
id= rs.getInt("id");
String update="UPDATE table_name SET active_flag=NULL WHERE id="+id+"";
stmt.executeUpdate(update);
}
i=1;
}
catch(Exception e)
{
System.out.println(e);
}
return i;
}
while running this, I am getting SQL Exception:
java.sql.SQLException: Operation not allowed after ResultSet closed
Please help me to perform this operation in an alternative and simple way. I just want to update the same table with the value obtained from first SQL Query, as there is n number of values in table and the value change dynamically, I used while loop. please help me to fix this. Thanks in advance.