提交 07ba5508 authored 作者: Thomas Mueller's avatar Thomas Mueller

The functions isBeforeFirst() and isAfterLast() were not compliant to the JDBC spec.

上级 b39ec761
...@@ -2427,7 +2427,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2427,7 +2427,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/** /**
* Checks if the current position is before the first row, that means next() * Checks if the current position is before the first row, that means next()
* was not called yet. * was not called yet, and there is at least one row.
* *
* @return if there are results and the current position is before the first row * @return if there are results and the current position is before the first row
* @throws SQLException if the result set is closed * @throws SQLException if the result set is closed
...@@ -2446,7 +2446,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2446,7 +2446,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/** /**
* Checks if the current position is after the last row, that means next() * Checks if the current position is after the last row, that means next()
* was called and returned false. * was called and returned false, and there was at least one row.
* *
* @return if there are results and the current position is after the last row * @return if there are results and the current position is after the last row
* @throws SQLException if the result set is closed * @throws SQLException if the result set is closed
......
...@@ -88,12 +88,12 @@ public class TestResultSet extends TestBase { ...@@ -88,12 +88,12 @@ public class TestResultSet extends TestBase {
deleteDb("resultSet"); deleteDb("resultSet");
} }
private void testBeforeFirstAfterLast() throws SQLException { private void testBeforeFirstAfterLast() throws SQLException {
stat.executeUpdate("create table test(id int)"); stat.executeUpdate("create table test(id int)");
stat.executeUpdate("insert into test values(1)"); stat.executeUpdate("insert into test values(1)");
// With a result // With a result
ResultSet rs = stat.executeQuery("select * from test"); ResultSet rs = stat.executeQuery("select * from test");
assertTrue(rs.isBeforeFirst()); assertTrue(rs.isBeforeFirst());
assertFalse(rs.isAfterLast()); assertFalse(rs.isAfterLast());
rs.next(); rs.next();
...@@ -104,7 +104,7 @@ public class TestResultSet extends TestBase { ...@@ -104,7 +104,7 @@ public class TestResultSet extends TestBase {
assertTrue(rs.isAfterLast()); assertTrue(rs.isAfterLast());
rs.close(); rs.close();
// With no result // With no result
rs = stat.executeQuery("select * from test where 1 = 2"); rs = stat.executeQuery("select * from test where 1 = 2");
assertFalse(rs.isBeforeFirst()); assertFalse(rs.isBeforeFirst());
assertFalse(rs.isAfterLast()); assertFalse(rs.isAfterLast());
rs.next(); rs.next();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论