Package java.sql

Examples of java.sql.ResultSet.previous()


        s.setCursorName(getNextCursorName());
        ResultSet rs = s.executeQuery("select * from t1");
       
        rs.last();
        rs.next();
        while(rs.previous()) {
            // Update the key of every second row.
            int key = rs.getInt(1);
            if (key%2==0) {
                int newKey = -key;
                rs.updateInt(1, newKey);
View Full Code Here


        rs.last();
        for (int i=0; i<10; i++) {
            rs.first();
            rs.last();
            rs.next();
            rs.previous();
            rs.updateInt(1, primaryKey*10 +i);
            rs.updateInt(2, (-555 -i));
            rs.updateInt(3, (-777 -i));
            rs.updateRow();
        }
View Full Code Here

        ResultSet rs = s.executeQuery("select * from t1");
       
        rs.last();
        rs.next();
        int newKey = 0;
        while(rs.previous()) {
            // Update the secondary key of all rows
            rs.updateInt(2, newKey--);
            rs.updateRow();
        }
        PreparedStatement ps = prepareStatement
View Full Code Here

        s.setCursorName("MYCURSOR");
        ResultSet rs = s.executeQuery("select * from t1 for update");
       
        rs.next();
        int pKey = rs.getInt(1);
        rs.previous();
        rs.next();
        assertEquals("Expecting to be on the same row after previous() " +
                     "+ next() ", pKey, rs.getInt(1));
        rs.next();
        rs.previous();
View Full Code Here

        rs.previous();
        rs.next();
        assertEquals("Expecting to be on the same row after previous() " +
                     "+ next() ", pKey, rs.getInt(1));
        rs.next();
        rs.previous();
        assertEquals("Expecting to be on the same row after next() + " +
                     "previous()", pKey, rs.getInt(1));
        final int previousA = rs.getInt(2);
        final int previousB = rs.getInt(3);
        println(rs.getCursorName());
View Full Code Here

            ("update T1 set a=?,b=? where current of " + rs.getCursorName());
        ps.setInt(1, 666);
        ps.setInt(2, 777);
        ps.executeUpdate();
        rs.next();
        rs.previous();
        assertEquals("Expected to be on the same row after next() + previous()",
                     pKey, rs.getInt(1));
        assertEquals("Expected row to be updated by own change, " +
                     " however did not get updated value for column a",
                     666, rs.getInt(2));
View Full Code Here

        rs.updateInt(1, rs.getInt(1) + 2 * recordCount);
        rs.updateRow();
        assertTrue("Expected rowUpdated() to return true", rs.rowUpdated());
        rs.deleteRow();
        rs.next();
        rs.previous();
        assertTrue("Expected rowUpdated() to return true", rs.rowUpdated());
        assertTrue("Expected rowDeleted() to return true", rs.rowDeleted());
        rs.next();
        assertFalse("Expected rowUpdated() to return false", rs.rowUpdated());
        assertFalse("Expected rowDeleted() to return false", rs.rowDeleted());
View Full Code Here

        assertTrue("Expected rowUpdated() to return true", rs.rowUpdated());
        assertTrue("Expected rowDeleted() to return true", rs.rowDeleted());
        rs.next();
        assertFalse("Expected rowUpdated() to return false", rs.rowUpdated());
        assertFalse("Expected rowDeleted() to return false", rs.rowDeleted());
        rs.previous();
        assertTrue("Expected rowUpdated() to return true", rs.rowUpdated());
        assertTrue("Expected rowDeleted() to return true", rs.rowDeleted());
        rs.close();
        s.close();
    }
View Full Code Here

        assertNotNull(rs);
        assertTrue(rs.last());

        // Iterate backwards thru RS, expect only 4 more (5 total) rows.
        for (int index = 1; index < 5; index++) {
            assertTrue(rs.previous());
        }
        // We should not see another row (only 5, not 6)
        assertFalse(rs.previous());
        rs.close();
        rs = s_i_r.executeQuery("values 1, 2, 3, 4, 5, 6");
View Full Code Here

        // Iterate backwards thru RS, expect only 4 more (5 total) rows.
        for (int index = 1; index < 5; index++) {
            assertTrue(rs.previous());
        }
        // We should not see another row (only 5, not 6)
        assertFalse(rs.previous());
        rs.close();
        rs = s_i_r.executeQuery("values 1, 2, 3, 4, 5, 6");
        assertNotNull(rs);

        rs.afterLast();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.