Re: Statement.close() and its current ResultSet
Ronald Klop <[email protected]>
| Newsgroups | gmane.comp.db.mysql.java |
|---|---|
| Message-ID | <6043817.151158692126850.JavaMail.tomcat@localhost> |
You are right, but it is 'allowed' for a JDBC implementation to not close the ResultSet when a new query is done. But if you change from JDBC connector you can't complain that you're application doesn't work anymore, because the specs say it wil close the ResultSet. Ronald. On Thu Sep 14 11:14:19 CEST 2006 "Johan Höök" <[email protected]> wrote: > 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]