i*****t 发帖数: 220 | 1 I use two database accessing methods in a loop like:
while ()
{
...
query = "select ...";
ResultSet r = statement.executeQuery(query);
update = "update...";
int ud = statement.executeUpdate(update);
...
}
The first query has no problem. No compiling errors. But when it runs, it says
the update method does not work because "ResultSet is closed." What is wrong
with it and how to fix it? Thanks. | e**o 发帖数: 131 | 2 your code must be within a try block and r is closed automatically when either
the Connection object or the Statement object is closed, which is highly
likely in some catch or finally clause.
says
【在 i*****t 的大作中提到】 : I use two database accessing methods in a loop like: : while () : { : ... : query = "select ..."; : ResultSet r = statement.executeQuery(query); : update = "update..."; : int ud = statement.executeUpdate(update); : ... : }
|
|