我正在尝试从结果集中的数据库中检索结果。但是,我想对结果集中的每个条目执行更新查询,但得到一个异常。
这是我的密码
try {
Statement statement = sqlconnection.conn.createStatement();
query = "select * from reminders where year<= "+ syear +" and month<=" + smonth +" and date<"+ sday +" and reminded like 'false';";
rs= statement.executeQuery(query);
while (rs.next()){
id=rs.getInt("sno");
String reminder = rs.getString("remind");
JOptionPane.showMessageDialog(null, reminder);
statement.executeUpdate("update reminders set reminded='true' where sno="+id+";");
}
有人能告诉我更好的方法吗??我对编程很陌生。因此,告诉我怎么做会很有帮助。
谢谢