java.sql.ResultSet#cancelRowUpdates ( )源码实例Demo

下面列出了java.sql.ResultSet#cancelRowUpdates ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Test(expected = SQLFeatureNotSupportedException.class)
public void assertCancelRowUpdates() throws SQLException {
    for (ResultSet each : resultSets) {
        each.cancelRowUpdates();
    }
}
 
源代码2 项目: gemfirexd-oss   文件: SURTest.java
/**
 * Test that you can correctly run multiple updateXXX() + updateRow() 
 * combined with cancelRowUpdates().
 */
public void testMultiUpdateRow1() 
    throws SQLException 
{
    Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
    s.setCursorName(getNextCursorName());
    ResultSet rs = s.executeQuery("select * from t1");
    rs.absolute(5);
    final int oldCol2 = rs.getInt(2);
    final int newCol2 = -2222;
    final int oldCol3 = rs.getInt(3);
    final int newCol3 = -3333;
            
    rs.updateInt(2, newCol2);
    assertEquals("Expected the resultset to be updated after updateInt",
                 newCol2, rs.getInt(2));
    rs.cancelRowUpdates();
    assertEquals("Expected updateXXX to have no effect after cancelRowUpdated",
                 oldCol2, rs.getInt(2));
    rs.updateInt(2, newCol2);
    assertEquals("Expected the resultset to be updated after updateInt", 
                 newCol2, rs.getInt(2));
    assertTrue("Expected rs.rowUpdated() to be false before updateRow", 
               !rs.rowUpdated());
    rs.updateRow();
    
    assertTrue("Expected rs.rowUpdated() to be true after updateRow", 
               rs.rowUpdated());
    assertEquals("Expected the resultset detect the updates of previous " + 
                 "updateRow", newCol2, rs.getInt(2));
    
    rs.updateInt(3, newCol3);
    
    assertEquals("Expected the resultset to be updated after updateInt", 
                 newCol3, rs.getInt(3));
    assertEquals("Expected the resultset detect the updates of previous " + 
                 "updateRow", newCol2, rs.getInt(2));
    
    rs.cancelRowUpdates();
    
    assertEquals("Expected updateXXX to have no effect after " +
                 "cancelRowUpdated", oldCol3, rs.getInt(3));
    assertEquals("Expected the resultset detect the updates of previous " +
                 "updateRow after cancelRowUpdated", newCol2, rs.getInt(2));
    rs.updateInt(3, newCol3);
    rs.updateRow();
    assertEquals("Expected the resultset to be updated after updateInt", 
                 newCol3, rs.getInt(3));
    rs.cancelRowUpdates();
    
    assertEquals("Expected the resultset detect the updates of previous" + 
                 "updateRow after cancelRowUpdates", newCol2, rs.getInt(2));
    assertEquals("Expected the resultset detect the updates of previous" + 
                 "updateRow after cancelRowUpdates", newCol3, rs.getInt(3));
    assertTrue("Expected rs.rowUpdated() to be true after " + 
               "updateRow and cancelRowUpdates", rs.rowUpdated());
    
    rs.close();
    s.close();
}
 
源代码3 项目: gemfirexd-oss   文件: SURTest.java
/**
 * Test that you can correctly run multiple updateNull() + updateRow() 
 * combined with cancelRowUpdates().
 */
public void testMultiUpdateRow2() 
    throws SQLException 
{
    Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
    s.setCursorName(getNextCursorName());
    ResultSet rs = s.executeQuery("select * from t1");
    rs.absolute(5);
    final int oldCol2 = rs.getInt(2);
    final int oldCol3 = rs.getInt(3);
    
    rs.updateNull(2);
    assertEquals("Expected the resultset to be updated after updateNull",
                 0, rs.getInt(2));
    assertTrue("Expected wasNull to be true after updateNull", rs.wasNull());
    rs.cancelRowUpdates();
    assertEquals("Expected updateXXX to have no effect after cancelRowUpdated",
                 oldCol2, rs.getInt(2));
    rs.updateNull(2);
    assertEquals("Expected the resultset to be updated after updateNull", 
                 0, rs.getInt(2));
    assertTrue("Expected wasNull to be true after updateNull", rs.wasNull());
    assertTrue("Expected rs.rowUpdated() to be false before updateRow", 
               !rs.rowUpdated());
    rs.updateRow();
    
    assertTrue("Expected rs.rowUpdated() to be true after updateRow", 
               rs.rowUpdated());
    assertEquals("Expected the resultset detect the updates of previous " + 
                 "updateRow", 0, rs.getInt(2));
    
    rs.updateNull(3);
    
    assertEquals("Expected the resultset to be updated after updateNull", 
                 0, rs.getInt(3));
    assertTrue("Expected wasNull to be true after updateNull", rs.wasNull());
    assertEquals("Expected the resultset detect the updates of previous " + 
                 "updateRow", 0, rs.getInt(2));
    
    rs.cancelRowUpdates();
    
    assertEquals("Expected updateXXX to have no effect after " +
                 "cancelRowUpdated", oldCol3, rs.getInt(3));
    assertEquals("Expected the resultset detect the updates of previous " +
                 "updateRow after cancelRowUpdated", 0, rs.getInt(2));
    rs.updateNull(3);
    rs.updateRow();
    assertEquals("Expected the resultset to be updated after updateNull", 
                 0, rs.getInt(3));
    rs.cancelRowUpdates();
    
    assertEquals("Expected the resultset detect the updates of previous" + 
                 "updateRow after cancelRowUpdates", 0, rs.getInt(2));
    assertEquals("Expected the resultset detect the updates of previous" + 
                 "updateRow after cancelRowUpdates", 0, rs.getInt(3));
    assertTrue("Expected rs.rowUpdated() to be true after " + 
               "updateRow and cancelRowUpdates", rs.rowUpdated());
    
    rs.close();
    s.close();
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertCancelRowUpdates() throws SQLException {
    for (ResultSet each : resultSets) {
        each.cancelRowUpdates();
    }
}
 
源代码5 项目: gemfirexd-oss   文件: SURTest.java
/**
 * Test that you can correctly run multiple updateXXX() + updateRow() 
 * combined with cancelRowUpdates().
 */
public void testMultiUpdateRow1() 
    throws SQLException 
{
    Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
    s.setCursorName(getNextCursorName());
    ResultSet rs = s.executeQuery("select * from t1");
    rs.absolute(5);
    final int oldCol2 = rs.getInt(2);
    final int newCol2 = -2222;
    final int oldCol3 = rs.getInt(3);
    final int newCol3 = -3333;
            
    rs.updateInt(2, newCol2);
    assertEquals("Expected the resultset to be updated after updateInt",
                 newCol2, rs.getInt(2));
    rs.cancelRowUpdates();
    assertEquals("Expected updateXXX to have no effect after cancelRowUpdated",
                 oldCol2, rs.getInt(2));
    rs.updateInt(2, newCol2);
    assertEquals("Expected the resultset to be updated after updateInt", 
                 newCol2, rs.getInt(2));
    assertTrue("Expected rs.rowUpdated() to be false before updateRow", 
               !rs.rowUpdated());
    rs.updateRow();
    
    assertTrue("Expected rs.rowUpdated() to be true after updateRow", 
               rs.rowUpdated());
    assertEquals("Expected the resultset detect the updates of previous " + 
                 "updateRow", newCol2, rs.getInt(2));
    
    rs.updateInt(3, newCol3);
    
    assertEquals("Expected the resultset to be updated after updateInt", 
                 newCol3, rs.getInt(3));
    assertEquals("Expected the resultset detect the updates of previous " + 
                 "updateRow", newCol2, rs.getInt(2));
    
    rs.cancelRowUpdates();
    
    assertEquals("Expected updateXXX to have no effect after " +
                 "cancelRowUpdated", oldCol3, rs.getInt(3));
    assertEquals("Expected the resultset detect the updates of previous " +
                 "updateRow after cancelRowUpdated", newCol2, rs.getInt(2));
    rs.updateInt(3, newCol3);
    rs.updateRow();
    assertEquals("Expected the resultset to be updated after updateInt", 
                 newCol3, rs.getInt(3));
    rs.cancelRowUpdates();
    
    assertEquals("Expected the resultset detect the updates of previous" + 
                 "updateRow after cancelRowUpdates", newCol2, rs.getInt(2));
    assertEquals("Expected the resultset detect the updates of previous" + 
                 "updateRow after cancelRowUpdates", newCol3, rs.getInt(3));
    assertTrue("Expected rs.rowUpdated() to be true after " + 
               "updateRow and cancelRowUpdates", rs.rowUpdated());
    
    rs.close();
    s.close();
}
 
源代码6 项目: gemfirexd-oss   文件: SURTest.java
/**
 * Test that you can correctly run multiple updateNull() + updateRow() 
 * combined with cancelRowUpdates().
 */
public void testMultiUpdateRow2() 
    throws SQLException 
{
    Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
    s.setCursorName(getNextCursorName());
    ResultSet rs = s.executeQuery("select * from t1");
    rs.absolute(5);
    final int oldCol2 = rs.getInt(2);
    final int oldCol3 = rs.getInt(3);
    
    rs.updateNull(2);
    assertEquals("Expected the resultset to be updated after updateNull",
                 0, rs.getInt(2));
    assertTrue("Expected wasNull to be true after updateNull", rs.wasNull());
    rs.cancelRowUpdates();
    assertEquals("Expected updateXXX to have no effect after cancelRowUpdated",
                 oldCol2, rs.getInt(2));
    rs.updateNull(2);
    assertEquals("Expected the resultset to be updated after updateNull", 
                 0, rs.getInt(2));
    assertTrue("Expected wasNull to be true after updateNull", rs.wasNull());
    assertTrue("Expected rs.rowUpdated() to be false before updateRow", 
               !rs.rowUpdated());
    rs.updateRow();
    
    assertTrue("Expected rs.rowUpdated() to be true after updateRow", 
               rs.rowUpdated());
    assertEquals("Expected the resultset detect the updates of previous " + 
                 "updateRow", 0, rs.getInt(2));
    
    rs.updateNull(3);
    
    assertEquals("Expected the resultset to be updated after updateNull", 
                 0, rs.getInt(3));
    assertTrue("Expected wasNull to be true after updateNull", rs.wasNull());
    assertEquals("Expected the resultset detect the updates of previous " + 
                 "updateRow", 0, rs.getInt(2));
    
    rs.cancelRowUpdates();
    
    assertEquals("Expected updateXXX to have no effect after " +
                 "cancelRowUpdated", oldCol3, rs.getInt(3));
    assertEquals("Expected the resultset detect the updates of previous " +
                 "updateRow after cancelRowUpdated", 0, rs.getInt(2));
    rs.updateNull(3);
    rs.updateRow();
    assertEquals("Expected the resultset to be updated after updateNull", 
                 0, rs.getInt(3));
    rs.cancelRowUpdates();
    
    assertEquals("Expected the resultset detect the updates of previous" + 
                 "updateRow after cancelRowUpdates", 0, rs.getInt(2));
    assertEquals("Expected the resultset detect the updates of previous" + 
                 "updateRow after cancelRowUpdates", 0, rs.getInt(3));
    assertTrue("Expected rs.rowUpdated() to be true after " + 
               "updateRow and cancelRowUpdates", rs.rowUpdated());
    
    rs.close();
    s.close();
}
 
源代码7 项目: spliceengine   文件: SURTest.java
/**
 * Test that you can correctly run multiple updateXXX() + updateRow() 
 * combined with cancelRowUpdates().
 */
public void testMultiUpdateRow1() 
    throws SQLException 
{
    Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
    s.setCursorName(getNextCursorName());
    ResultSet rs = s.executeQuery("select * from t1");
    rs.absolute(5);
    final int oldCol2 = rs.getInt(2);
    final int newCol2 = -2222;
    final int oldCol3 = rs.getInt(3);
    final int newCol3 = -3333;
            
    rs.updateInt(2, newCol2);
    assertEquals("Expected the resultset to be updated after updateInt",
                 newCol2, rs.getInt(2));
    rs.cancelRowUpdates();
    assertEquals("Expected updateXXX to have no effect after cancelRowUpdated",
                 oldCol2, rs.getInt(2));
    rs.updateInt(2, newCol2);
    assertEquals("Expected the resultset to be updated after updateInt", 
                 newCol2, rs.getInt(2));
    assertTrue("Expected rs.rowUpdated() to be false before updateRow", 
               !rs.rowUpdated());
    rs.updateRow();
    
    assertTrue("Expected rs.rowUpdated() to be true after updateRow", 
               rs.rowUpdated());
    assertEquals("Expected the resultset detect the updates of previous " + 
                 "updateRow", newCol2, rs.getInt(2));
    
    rs.updateInt(3, newCol3);
    
    assertEquals("Expected the resultset to be updated after updateInt", 
                 newCol3, rs.getInt(3));
    assertEquals("Expected the resultset detect the updates of previous " + 
                 "updateRow", newCol2, rs.getInt(2));
    
    rs.cancelRowUpdates();
    
    assertEquals("Expected updateXXX to have no effect after " +
                 "cancelRowUpdated", oldCol3, rs.getInt(3));
    assertEquals("Expected the resultset detect the updates of previous " +
                 "updateRow after cancelRowUpdated", newCol2, rs.getInt(2));
    rs.updateInt(3, newCol3);
    rs.updateRow();
    assertEquals("Expected the resultset to be updated after updateInt", 
                 newCol3, rs.getInt(3));
    rs.cancelRowUpdates();
    
    assertEquals("Expected the resultset detect the updates of previous" + 
                 "updateRow after cancelRowUpdates", newCol2, rs.getInt(2));
    assertEquals("Expected the resultset detect the updates of previous" + 
                 "updateRow after cancelRowUpdates", newCol3, rs.getInt(3));
    assertTrue("Expected rs.rowUpdated() to be true after " + 
               "updateRow and cancelRowUpdates", rs.rowUpdated());
    
    rs.close();
    s.close();
}
 
源代码8 项目: spliceengine   文件: SURTest.java
/**
 * Test that you can correctly run multiple updateNull() + updateRow() 
 * combined with cancelRowUpdates().
 */
public void testMultiUpdateRow2() 
    throws SQLException 
{
    Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
    s.setCursorName(getNextCursorName());
    ResultSet rs = s.executeQuery("select * from t1");
    rs.absolute(5);
    final int oldCol2 = rs.getInt(2);
    final int oldCol3 = rs.getInt(3);
    
    rs.updateNull(2);
    assertEquals("Expected the resultset to be updated after updateNull",
                 0, rs.getInt(2));
    assertTrue("Expected wasNull to be true after updateNull", rs.wasNull());
    rs.cancelRowUpdates();
    assertEquals("Expected updateXXX to have no effect after cancelRowUpdated",
                 oldCol2, rs.getInt(2));
    rs.updateNull(2);
    assertEquals("Expected the resultset to be updated after updateNull", 
                 0, rs.getInt(2));
    assertTrue("Expected wasNull to be true after updateNull", rs.wasNull());
    assertTrue("Expected rs.rowUpdated() to be false before updateRow", 
               !rs.rowUpdated());
    rs.updateRow();
    
    assertTrue("Expected rs.rowUpdated() to be true after updateRow", 
               rs.rowUpdated());
    assertEquals("Expected the resultset detect the updates of previous " + 
                 "updateRow", 0, rs.getInt(2));
    
    rs.updateNull(3);
    
    assertEquals("Expected the resultset to be updated after updateNull", 
                 0, rs.getInt(3));
    assertTrue("Expected wasNull to be true after updateNull", rs.wasNull());
    assertEquals("Expected the resultset detect the updates of previous " + 
                 "updateRow", 0, rs.getInt(2));
    
    rs.cancelRowUpdates();
    
    assertEquals("Expected updateXXX to have no effect after " +
                 "cancelRowUpdated", oldCol3, rs.getInt(3));
    assertEquals("Expected the resultset detect the updates of previous " +
                 "updateRow after cancelRowUpdated", 0, rs.getInt(2));
    rs.updateNull(3);
    rs.updateRow();
    assertEquals("Expected the resultset to be updated after updateNull", 
                 0, rs.getInt(3));
    rs.cancelRowUpdates();
    
    assertEquals("Expected the resultset detect the updates of previous" + 
                 "updateRow after cancelRowUpdates", 0, rs.getInt(2));
    assertEquals("Expected the resultset detect the updates of previous" + 
                 "updateRow after cancelRowUpdates", 0, rs.getInt(3));
    assertTrue("Expected rs.rowUpdated() to be true after " + 
               "updateRow and cancelRowUpdates", rs.rowUpdated());
    
    rs.close();
    s.close();
}