I don't think that's what they mean. According to http://onjava.com/onjava/excerpt/javaentnut_2/index2.html section "Multiple Result Sets":

It is possible to write a SQL statement that returns more than one |ResultSet| or update count (exact methods of doing so vary depending on the database). [...] To be sure you've processed all the results for a |Statement|, you need to check that |getMoreResults( )| returns |false| and that |getUpdateCount( )| returns |-1|.

And actually if you look at the Javadoc for getMoreResults() it seems to back up their claim. It provides example code that shows them doing exactly what is mentioned above (waiting for getUpdateCount() to become -1). Notice that they imply invoking getUpdateCount() multiple times (once per result).

Gili

On 01/05/2012 11:08 PM, Igal wrote:
I think that getUpdateCount() in org.h2.jdbc.JdbcStatement.getUpdateCount() is not working according to standards.

*-----*
according to docs at http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html#getUpdateCount() <http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html#getUpdateCount%28%29>

int getUpdateCount() throws SQLException :

Retrieves the current result as an update count; if the result is a ResultSet object or there are no more results, -1 is returned. *This method should be called only once per result*.

Returns: the current result as an update count; *-1 if* the current result is a ResultSet object or*there are no more results *
*-----*

it seems to me that the first time this method is called it should return the Update Count, but if it is called a second time it should return -1, i.e. line 222 should be changed to something like this:

  int result = updateCount;
  updateCount = -1;         // for subsequent calls
  return result;

I'm trying to use H2 from Railo (https://groups.google.com/forum/#!forum/railo <https://groups.google.com/forum/#%21forum/railo>) and am experiencing a problem reported at https://issues.jboss.org/browse/RAILO-1638

thank you for your consideration,


Igal


--
You received this message because you are subscribed to the Google Groups "H2 Database" group. To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/hY30Mzoc3LEJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to