sagarswathi / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

ResultSet.absolute(0) should be rejected #508

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The JavaDoc of org.h2.jdbc.JdbcResultSet.absolute(int) says "0 is not allowed, 
1 means the first row" and that seems to be inline with the documented contract 
of java.sql.ResultSet.absolute(int).

But the H2 implementation of this method returns the first row for 0, the 
second for 1, and so on.

I tested this with H2 v1.3.168.

Original issue reported on code.google.com by eike.ste...@googlemail.com on 26 Sep 2013 at 9:27

GoogleCodeExporter commented 8 years ago
Please provide a simple, reproducible test case.

Original comment by thomas.t...@gmail.com on 26 Sep 2013 at 10:08

GoogleCodeExporter commented 8 years ago
I wrote a small test case and found out that the problem was really mostly in 
my code. I thought that after the absolute() call I have to call next(), 
similar to a freshly created ResultSet. So in my own code the following calls 
resulted in what I expected:

  resultSet.absolute(0);
  resultSet.next();

That is the first row. But this should really have been just:

  resultSet.absolute(1)

Without the call to next(). Oracle throws an exception on absolute(0) and it 
would have helped me to find my own bug if H2 had thrown a similar exception. I 
leave it up to you whether that's an important enough issue or not ;-)

Original comment by eike.ste...@googlemail.com on 26 Sep 2013 at 10:37

GoogleCodeExporter commented 8 years ago
OK I see. I will check what other databases do on rs.absolute(0), and the JDBC 
specification. Thanks a lot!

Original comment by thomas.t...@gmail.com on 26 Sep 2013 at 11:43

GoogleCodeExporter commented 8 years ago

Original comment by thomas.t...@gmail.com on 19 Oct 2013 at 8:40

GoogleCodeExporter commented 8 years ago
The JDBC spec says "If the row number specified is zero, the cursor is moved to 
before the first row."

See also 
http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.html#absolute(int)

So I set this issue to "Invalid" for now.

Original comment by thomas.t...@gmail.com on 14 Dec 2013 at 7:36