/** * <p> * Moves the cursor to the first row in this ResultSet object. * </p> * * @return true if the cursor is on valid row, false if there are no rows in * the resultset. * @throws SQLException * if the ResulSet is of TYPE_FORWARD_ONLY. */ public boolean first() throws SQLException { checkNotForwardOnly(); return absolute(1); }
/** * <p> * Moves the cursor to the first row in this ResultSet object. * </p> * * @return true if the cursor is on valid row, false if there are no rows in * the resultset. * @throws SQLException * if the ResulSet is of TYPE_FORWARD_ONLY. */ public boolean first() throws SQLException { checkNotForwardOnly(); return absolute(1); }
@Test(expected=SQLException.class) public void testAbsolute1() throws Exception { ResultSetImpl rs = helpGetResultSetImpl(TYPE_FORWARD_ONLY); rs.absolute(1); }
/** test hasNext() with blocking for the Next batch -- triggering point */ @Test public void testHasNext2() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); cs.absolute(100); assertEquals(" hasNext() doesn't match expected value. ", true, cs.hasNext()); //$NON-NLS-1$ cs.close(); }
/** test cursor at the last row of all batches */ @Test public void testIsLast3() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); cs.absolute(1000); assertTrue(cs.isLast()); cs.close(); }
/** absolute after last row */ @Test public void testAbsolute6() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); cs.absolute(1005); // Cursor should be after last row. getRow() should return 0 because // cursor is not on a valid row assertEquals(" Current row number doesn't match with expected one.", 0, cs.getRow()); //$NON-NLS-1$ cs.close(); }
/** test only valid row in result set */ @Test public void testAbsolute2a() throws Exception { ResultSetImpl rs = helpGetNoResults(TYPE_SCROLL_SENSITIVE); // start from beginning assertEquals(false, rs.absolute(1)); assertEquals(0, rs.getRow()); // start from right after last rs.afterLast(); assertEquals(false, rs.absolute(-1)); assertEquals(0, rs.getRow()); rs.close(); }
/** at the end of all batches */ @Test public void testHasNext4() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); cs.absolute(1000); assertTrue(!cs.hasNext()); cs.close(); }
/** test rare case that cursor change direction */ @Test public void testChangeDirection() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); cs.absolute(291); cs.previous(); assertEquals(" current row doesn't match expected value. ", 290, cs.getRow()); //$NON-NLS-1$ cs.close(); }
/** right after the last row */ @Test public void testIsAfterLast1() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); cs.absolute(1000); cs.next(); assertTrue(cs.isAfterLast()); cs.close(); }
/** test the previous in the middle of a batch */ @Test public void testPrevious2() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); cs.absolute(290); // cursor is at the row of 289 now assertTrue(cs.previous()); assertEquals(" current row doesn't match expected value. ", 289, cs.getRow()); //$NON-NLS-1$ cs.close(); }
/** relative(positive) -- forward to another batch */ @Test public void testRelative1() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); // move to the row #3 cs.absolute(3); assertEquals(" Current row number doesn't match with expected one.", 3, cs.getRow()); //$NON-NLS-1$ // move to the row #140 cs.relative(137); assertEquals(" Current row number doesn't match with expected one.", 140, cs.getRow()); //$NON-NLS-1$ cs.close(); }
/** relative(negative) -- backward to another batch */ @Test public void testRelative2() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); // move to the row #137 cs.absolute(137); assertEquals(" Current row number doesn't match with expected one.", 137, cs.getRow()); //$NON-NLS-1$ // move to the row #4 cs.relative(-133); assertEquals(" Current row number doesn't match with expected one.", 4, cs.getRow()); //$NON-NLS-1$ cs.close(); }
/** relative(negative) -- backward to triggering point or blocking batch */ @Test public void testRelative3() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); // move to the row #137 cs.absolute(137); assertEquals(" Current row number doesn't match with expected one.", 137, cs.getRow()); //$NON-NLS-1$ // move to the row #100 cs.relative(-37); assertEquals(" Current row number doesn't match with expected one.", 100, cs.getRow()); //$NON-NLS-1$ cs.close(); }
/** relative(negative) -- backward to triggering point or blocking batch */ @Test public void testRelative4() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); // move to the row #237 in the third batch, so that the fourth batch has been requested when we switch direction cs.absolute(237); assertEquals(" Current row number doesn't match with expected one.", 237, cs.getRow()); //$NON-NLS-1$ // move to the row #37 cs.relative(-200); assertEquals(" Current row number doesn't match with expected one.", 37, cs.getRow()); //$NON-NLS-1$ cs.close(); }
/** absolute with cursor movement forward in the same batch -- absolute(positive) */ @Test public void testAbsolute2() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); // move to row #2 cs.next(); cs.next(); assertEquals(" Current row number doesn't match with expected one.", 2, cs.getRow()); //$NON-NLS-1$ // move back to the 1st row cs.absolute(3); assertEquals(" Current row number doesn't match with expected one.", 3, cs.getRow()); //$NON-NLS-1$ cs.close(); }
/** absolute with cursor movement forward -- absolute(positive) -- blocking */ @Test public void testAbsolute3() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); // move to row #2 cs.next(); cs.next(); assertEquals(" Current row number doesn't match with expected one.", 2, cs.getRow()); //$NON-NLS-1$ // move to row #100 -- blocking cs.absolute(100); assertEquals(" Current row number doesn't match with expected one.", 100, cs.getRow()); //$NON-NLS-1$ cs.close(); }
/** absolute with cursor movement back in the same batch -- absolute(negative) */ @Test public void testAbsolute5() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); // move to row #2 cs.next(); cs.next(); assertEquals(" Current row number doesn't match with expected one.", 2, cs.getRow()); //$NON-NLS-1$ // move back to the 1st row cs.absolute(-1); assertEquals(" Current row number doesn't match with expected one.", 1000, cs.getRow()); //$NON-NLS-1$ cs.close(); }
/** absolute with cursor movement backward in the same batch -- absolute(positive) */ @Test public void testAbsolute1() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); // move to row #2 cs.next(); cs.next(); assertEquals(" Current row number doesn't match with expected one.", 2, cs.getRow()); //$NON-NLS-1$ // move back to the 1st row cs.absolute(1); assertEquals(" Current row number doesn't match with expected one.", 1, cs.getRow()); //$NON-NLS-1$ cs.close(); }
/** absolute with cursor movement forward -- absolute(positive) -- triggering point */ @Test public void testAbsolute4() throws SQLException { ResultSetImpl cs = helpExecuteQuery(); // move to row #2 cs.next(); cs.next(); assertEquals(" Current row number doesn't match with expected one.", 2, cs.getRow()); //$NON-NLS-1$ // move to row #200 -- new batch cs.absolute(200); assertEquals(" Current row number doesn't match with expected one.", 200, cs.getRow()); //$NON-NLS-1$ cs.close(); }