当前位置: 首页>>代码示例>>Java>>正文


Java FilteredRowSet类代码示例

本文整理汇总了Java中javax.sql.rowset.FilteredRowSet的典型用法代码示例。如果您正苦于以下问题:Java FilteredRowSet类的具体用法?Java FilteredRowSet怎么用?Java FilteredRowSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FilteredRowSet类属于javax.sql.rowset包,在下文中一共展示了FilteredRowSet类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCreateCopy

import javax.sql.rowset.FilteredRowSet; //导入依赖的package包/类
public void testCreateCopy() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    if ("true".equals(System.getProperty("Testing Harmony"))) {
        filteredRowSet.createCopy();
    } else {
        try {
            filteredRowSet.createCopy();
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:FilteredRowSetTest.java

示例2: testPopulate

import javax.sql.rowset.FilteredRowSet; //导入依赖的package包/类
public void testPopulate() throws Exception {
    /*
     * Set Filter before populate()
     */
    RangeOne range = new RangeOne();
    FilteredRowSet filteredRowSet = newFilterRowSet();
    filteredRowSet.setFilter(range);
    assertSame(range, filteredRowSet.getFilter());

    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    assertTrue(filteredRowSet.first());
    assertEquals(2, filteredRowSet.getInt(1));

    filteredRowSet.setFilter(null);
    assertTrue(filteredRowSet.first());
    assertEquals(1, filteredRowSet.getInt(1));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:FilteredRowSetTest.java

示例3: testNextAndPrevious

import javax.sql.rowset.FilteredRowSet; //导入依赖的package包/类
public void testNextAndPrevious() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    RangeOne range = new RangeOne();
    filteredRowSet.setFilter(range);

    assertTrue(filteredRowSet.next());
    assertEquals(2, filteredRowSet.getInt(1));
    assertEquals(EVALUATE_ROWSET, range.getTag());
    assertEquals(2, range.getCount());
    range.clear();
    assertTrue(filteredRowSet.next());
    assertEquals(3, filteredRowSet.getInt(1));
    assertEquals(EVALUATE_ROWSET, range.getTag());
    assertEquals(1, range.getCount());

    range.clear();
    assertTrue(filteredRowSet.previous());
    assertEquals(2, filteredRowSet.getInt(1));
    assertEquals(1, range.getCount());
    range.clear();
    assertFalse(filteredRowSet.previous());
    assertEquals(EVALUATE_ROWSET, range.getTag());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:FilteredRowSetTest.java

示例4: testCreateShared

import javax.sql.rowset.FilteredRowSet; //导入依赖的package包/类
public void testCreateShared() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    FilteredRowSet copyFilteredRs = (FilteredRowSet) filteredRowSet
            .createShared();
    assertSame(range, copyFilteredRs.getFilter());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:FilteredRowSetTest.java

示例5: testRelative

import javax.sql.rowset.FilteredRowSet; //导入依赖的package包/类
public void testRelative() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    assertTrue(filteredRowSet.absolute(3));
    assertEquals(3, filteredRowSet.getInt(1));
    assertFalse(filteredRowSet.relative(2));

    assertTrue(filteredRowSet.absolute(3));
    assertEquals(3, filteredRowSet.getInt(1));
    assertTrue(filteredRowSet.relative(1));
    assertEquals(4, filteredRowSet.getInt(1));

    assertTrue(filteredRowSet.absolute(3));
    assertEquals(3, filteredRowSet.getInt(1));
    assertTrue(filteredRowSet.relative(-1));
    assertEquals(2, filteredRowSet.getInt(1));
    assertFalse(filteredRowSet.relative(-2));

    RangeOne range = new RangeOne();
    filteredRowSet.setFilter(range);

    filteredRowSet.beforeFirst();
    assertTrue(filteredRowSet.relative(2));
    assertEquals(3, filteredRowSet.getInt(1));
    assertEquals(3, filteredRowSet.getRow());
    assertFalse(filteredRowSet.relative(-2));
    assertTrue(filteredRowSet.isBeforeFirst());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:31,代码来源:FilteredRowSetTest.java

示例6: testNoFilter_Insert

import javax.sql.rowset.FilteredRowSet; //导入依赖的package包/类
public void testNoFilter_Insert() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    /*
     * TODO Call updateXXX() would throw NullPointerException on insert row
     * when running on RI.
     */
    filteredRowSet.moveToInsertRow();
    filteredRowSet.updateInt(1, 10);
    filteredRowSet.updateString(2, "insert10");
    filteredRowSet.insertRow();
    filteredRowSet.moveToCurrentRow();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:FilteredRowSetTest.java

示例7: testFilter_Update

import javax.sql.rowset.FilteredRowSet; //导入依赖的package包/类
public void testFilter_Update() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    /*
     * Update the third row. Filter has no effect here.
     */
    assertTrue(filteredRowSet.last());
    assertEquals("test4", filteredRowSet.getString(2));
    filteredRowSet.updateString(2, "update4");
    filteredRowSet.updateRow();
    assertEquals("update4", filteredRowSet.getString(2));
    // the updated row becomes not visible through filter
    assertTrue(filteredRowSet.last());
    assertEquals("test3", filteredRowSet.getString(2));

    // commit to database
    filteredRowSet.acceptChanges(conn);
    rs = st
            .executeQuery("SELECT COUNT(*) FROM USER_INFO WHERE NAME = 'update4'");
    assertTrue(rs.next());
    assertEquals(0, rs.getInt(1));

    /*
     * Remove filter
     */
    filteredRowSet.setFilter(null);
    assertTrue(filteredRowSet.last());
    assertEquals("update4", filteredRowSet.getString(2));
    /*
     * The forth row isn't updated to database, and it lost it's status
     * after acceptChanges().
     */
    assertFalse(filteredRowSet.rowUpdated());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:40,代码来源:FilteredRowSetTest.java

示例8: testFilter_Delete

import javax.sql.rowset.FilteredRowSet; //导入依赖的package包/类
public void testFilter_Delete() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    /*
     * Mark the first row as delete.
     */
    assertTrue(filteredRowSet.first());
    assertEquals(1, filteredRowSet.getInt(1));
    filteredRowSet.deleteRow();

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    assertTrue(filteredRowSet.first());
    assertEquals(2, filteredRowSet.getInt(1));

    filteredRowSet.acceptChanges(conn);
    rs = st.executeQuery("SELECT COUNT(*) FROM USER_INFO WHERE ID = 1");
    assertTrue(rs.next());
    assertEquals(1, rs.getInt(1));

    /*
     * Remove filter
     */
    filteredRowSet.setFilter(null);
    filteredRowSet.acceptChanges(conn);
    rs = st.executeQuery("SELECT COUNT(*) FROM USER_INFO WHERE ID = 1");
    assertTrue(rs.next());
    assertEquals(1, rs.getInt(1));
    /*
     * The first row has been deleted from FilteredRowSet. However, it isn't
     * deleted from database.
     */
    filteredRowSet.setShowDeleted(true);
    assertTrue(filteredRowSet.first());
    assertEquals(2, filteredRowSet.getInt(1));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:40,代码来源:FilteredRowSetTest.java

示例9: newFilterRowSet

import javax.sql.rowset.FilteredRowSet; //导入依赖的package包/类
protected FilteredRowSet newFilterRowSet() throws Exception {
    try {
        return (FilteredRowSet) Class.forName(
                "com.sun.rowset.FilteredRowSetImpl").newInstance();
    } catch (ClassNotFoundException e) {
        return (FilteredRowSet) Class
                .forName(
                        "org.apache.harmony.sql.internal.rowset.FilteredRowSetImpl")
                .newInstance();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:FilteredRowSetTest.java

示例10: createFilteredRowSet

import javax.sql.rowset.FilteredRowSet; //导入依赖的package包/类
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new com.sun.rowset.FilteredRowSetImpl();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:RowSetFactoryImpl.java

示例11: createFilteredRowSet

import javax.sql.rowset.FilteredRowSet; //导入依赖的package包/类
@Override
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new StubFilteredRowSetImpl();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:StubRowSetFactory.java

示例12: newInstance

import javax.sql.rowset.FilteredRowSet; //导入依赖的package包/类
protected FilteredRowSet newInstance() throws SQLException {
    return rsf.createFilteredRowSet();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:4,代码来源:FilteredRowSetTests.java


注:本文中的javax.sql.rowset.FilteredRowSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。