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

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

源代码1 项目: gemfirexd-oss   文件: UpdateXXXTest.java
/**
 * Tests calling setNull on all columns
 * @exception SQLException database access error. Causes test to 
 *                         fail with an error.
 */
public void testUpdateNull() 
    throws SQLException
{
    Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY, 
            ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = s.executeQuery(SELECT_STMT);
    rs.next();

    for (int i = 1; i <= COLUMNS; i++) {
        rs.updateNull(i);
        assertNull("Expected rs.getObject(" + i + ") to be null", 
                   rs.getObject(i));
        assertTrue("Expected rs.wasNull() to return true",
                   rs.wasNull());
    }
    rs.updateRow();
    rs.close();
    checkColumnsAreNull();
    
    s.close();
}
 
源代码2 项目: gemfirexd-oss   文件: UpdateVTIResultSet.java
private void updateVTI(ResultSet target, ExecRow row)
	throws StandardException
{
       int[] changedColumnIds = constants.changedColumnIds;
	try
	{
           for( int i = 0; i < changedColumnIds.length; i++)
           {
               int columnId = changedColumnIds[i];
               DataValueDescriptor newValue = row.getColumn( i + 1);
               if( newValue.isNull())
                   target.updateNull( columnId);
               else
                   newValue.setInto( target, columnId);
           }
           target.updateRow();
       }
	catch (Throwable t)
	{
		throw StandardException.unexpectedUserException(t);
	}
}
 
源代码3 项目: gemfirexd-oss   文件: UpdateXXXTest.java
/**
 * Tests calling setNull on all columns
 * @exception SQLException database access error. Causes test to 
 *                         fail with an error.
 */
public void testUpdateNull() 
    throws SQLException
{
    Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY, 
            ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = s.executeQuery(SELECT_STMT);
    rs.next();

    for (int i = 1; i <= COLUMNS; i++) {
        rs.updateNull(i);
        assertNull("Expected rs.getObject(" + i + ") to be null", 
                   rs.getObject(i));
        assertTrue("Expected rs.wasNull() to return true",
                   rs.wasNull());
    }
    rs.updateRow();
    rs.close();
    checkColumnsAreNull();
    
    s.close();
}
 
源代码4 项目: gemfirexd-oss   文件: UpdateVTIResultSet.java
private void updateVTI(ResultSet target, ExecRow row)
	throws StandardException
{
       int[] changedColumnIds = constants.changedColumnIds;
	try
	{
           for( int i = 0; i < changedColumnIds.length; i++)
           {
               int columnId = changedColumnIds[i];
               DataValueDescriptor newValue = row.getColumn( i + 1);
               if( newValue.isNull())
                   target.updateNull( columnId);
               else
                   newValue.setInto( target, columnId);
           }
           target.updateRow();
       }
	catch (Throwable t)
	{
		throw StandardException.unexpectedUserException(t);
	}
}
 
源代码5 项目: spliceengine   文件: UpdateXXXTest.java
/**
 * Tests calling setNull on all columns
 * @exception SQLException database access error. Causes test to 
 *                         fail with an error.
 */
public void testUpdateNull() 
    throws SQLException
{
    Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY, 
            ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = s.executeQuery(SELECT_STMT);
    rs.next();

    for (int i = 1; i <= COLUMNS; i++) {
        rs.updateNull(i);
        assertNull("Expected rs.getObject(" + i + ") to be null", 
                   rs.getObject(i));
        assertTrue("Expected rs.wasNull() to return true",
                   rs.wasNull());
    }
    rs.updateRow();
    rs.close();
    checkColumnsAreNull();
    
    s.close();
}
 
源代码6 项目: sqlbuilder   文件: QueryReader.java
/**
 * Calls updateNull on the given ResultSet with the given sql type
 * for the position of this PlaceHolder.
 */
public void updateNull(ResultSet rs)
  throws SQLException
{
  if(isInQuery()) {
    rs.updateNull(getIndex());
  }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateNullForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateNull(1);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateNullForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateNull("label");
    }
}
 
源代码9 项目: 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 assertUpdateNullForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateNull(1);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertUpdateNullForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.updateNull("label");
    }
}
 
源代码12 项目: 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();
}
 
源代码13 项目: 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();
}