Re: Statement.close() and its current ResultSet
Johan Höök <[email protected]>
| Newsgroups | gmane.comp.db.mysql.java |
|---|---|
| Message-ID | <[email protected]> |
Hi,
as far as I know another call to executeQuery on
a statement will close the previous resultset generated
on that statement, i.e. you can't do something like
ResultSet rs1 = stmt.executeQuery(...);
ResultSet rs2 = null;
while( rs1.next() )
{
rs2 = stmt.excuteQuery(...);
}
as rs1 is closed on the first consecutive call.
You'll have to use two different Statements.
/Johan
wolverine my skrev:
> Hi!
>
> The Java API documentation of Statement.close() mentioned that "A
> Statement object is automatically closed when it is garbage collected.
> When a Statement object is closed, its current ResultSet object, if
> one exists, is also closed."
> Based on the following codes:
>
> Statement stmt = conn.createStatme();
> ResultSet rs1 = stmt.executeQuery(...);
> ResultSet rs2 = stmt.executeQuery(...);
> stmt.close();
>
> When the close() is called, only the current ResultSet rs2 will be closed?
> How about rs2?
>
--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe: http://lists.mysql.com/[email protected]