/** * <p> * Moves the cursor to the front of the result set, just before the first * row. Has no effect if the result set contains no rows. * </p> * * @exception SQLException * if a results can not be accessed or the result set type is * TYPE_FORWARD_ONLY */ public void beforeFirst() throws SQLException { if (first()) { previous(); } }
/** * <p> * Moves the cursor to the front of the result set, just before the first * row. Has no effect if the result set contains no rows. * </p> * * @exception SQLException * if a results can not be accessed or the result set type is * TYPE_FORWARD_ONLY */ public void beforeFirst() throws SQLException { if (first()) { previous(); } }
@Test(expected=SQLException.class) public void testFirst1() throws Exception { ResultSetImpl rs = helpGetResultSetImpl(TYPE_FORWARD_ONLY); // move cursor to the first row rs.next(); rs.first(); }
@Test(expected=SQLException.class) public void testFirst2() throws Exception { ResultSetImpl rs = helpGetNoResults(TYPE_FORWARD_ONLY); // move cursor to the first row rs.next(); rs.first(); }
@Test public void testFirst1a() throws Exception { ResultSetImpl rs = helpGetResultSetImpl(TYPE_SCROLL_SENSITIVE); // move cursor to the first row boolean actual = rs.first(); assertEquals(true, actual); assertEquals(1, rs.getRow()); // move cursor to the first row starting from the last row rs.afterLast(); actual = rs.first(); assertEquals(true, actual); assertEquals(1, rs.getRow()); // move cursor to the first row from random number; rs.absolute(3); actual = rs.first(); assertEquals(true, actual); assertEquals(1, rs.getRow()); rs.close(); }
break; case FIRST: singleResult = rs.first(); break; case LAST:
@Test public void testFirst() 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.first(); assertEquals(" Current row number doesn't match with expected one.", 1, cs.getRow()); //$NON-NLS-1$ cs.close(); }