Java 类javax.sql.rowset.FilteredRowSet 实例源码

项目:cn1    文件:FilteredRowSetTest.java   
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
        }
    }
}
项目:cn1    文件:FilteredRowSetTest.java   
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));
}
项目:cn1    文件:FilteredRowSetTest.java   
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());
}
项目:freeVM    文件:FilteredRowSetTest.java   
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
        }
    }
}
项目:freeVM    文件:FilteredRowSetTest.java   
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));
}
项目:freeVM    文件:FilteredRowSetTest.java   
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());
}
项目:cn1    文件:FilteredRowSetTest.java   
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());
}
项目:cn1    文件:FilteredRowSetTest.java   
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());
}
项目:cn1    文件:FilteredRowSetTest.java   
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();
}
项目:cn1    文件:FilteredRowSetTest.java   
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());
}
项目:cn1    文件:FilteredRowSetTest.java   
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));
}
项目:cn1    文件:FilteredRowSetTest.java   
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();
    }
}
项目:cn1    文件:JoinRowSetTestCase.java   
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();
    }
}
项目:freeVM    文件:FilteredRowSetTest.java   
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());
}
项目:freeVM    文件:FilteredRowSetTest.java   
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());
}
项目:freeVM    文件:FilteredRowSetTest.java   
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());
}
项目:freeVM    文件:FilteredRowSetTest.java   
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));
}
项目:freeVM    文件:FilteredRowSetTest.java   
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();
    }
}
项目:freeVM    文件:JoinRowSetTestCase.java   
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();
    }
}
项目:OpenJSharp    文件:RowSetFactoryImpl.java   
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new com.sun.rowset.FilteredRowSetImpl();
}
项目:jdk8u-jdk    文件:RowSetFactoryImpl.java   
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new com.sun.rowset.FilteredRowSetImpl();
}
项目:jdk8u-jdk    文件:StubRowSetFactory.java   
@Override
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new StubFilteredRowSetImpl();
}
项目:jdk8u-jdk    文件:FilteredRowSetTests.java   
protected FilteredRowSet newInstance() throws SQLException {
    return rsf.createFilteredRowSet();
}
项目:openjdk-jdk10    文件:RowSetFactoryImpl.java   
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new com.sun.rowset.FilteredRowSetImpl();
}
项目:openjdk-jdk10    文件:StubRowSetFactory.java   
@Override
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new StubFilteredRowSetImpl();
}
项目:openjdk-jdk10    文件:FilteredRowSetTests.java   
protected FilteredRowSet newInstance() throws SQLException {
    return rsf.createFilteredRowSet();
}
项目:openjdk9    文件:RowSetFactoryImpl.java   
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new com.sun.rowset.FilteredRowSetImpl();
}
项目:openjdk9    文件:StubRowSetFactory.java   
@Override
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new StubFilteredRowSetImpl();
}
项目:openjdk9    文件:FilteredRowSetTests.java   
protected FilteredRowSet newInstance() throws SQLException {
    return rsf.createFilteredRowSet();
}
项目:jdk8u_jdk    文件:RowSetFactoryImpl.java   
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new com.sun.rowset.FilteredRowSetImpl();
}
项目:jdk8u_jdk    文件:StubRowSetFactory.java   
@Override
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new StubFilteredRowSetImpl();
}
项目:jdk8u_jdk    文件:FilteredRowSetTests.java   
protected FilteredRowSet newInstance() throws SQLException {
    return rsf.createFilteredRowSet();
}
项目:lookaside_java-1.8.0-openjdk    文件:RowSetFactoryImpl.java   
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new com.sun.rowset.FilteredRowSetImpl();
}
项目:lookaside_java-1.8.0-openjdk    文件:StubRowSetFactory.java   
@Override
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new StubFilteredRowSetImpl();
}
项目:lookaside_java-1.8.0-openjdk    文件:FilteredRowSetTests.java   
protected FilteredRowSet newInstance() throws SQLException {
    return rsf.createFilteredRowSet();
}
项目:infobip-open-jdk-8    文件:RowSetFactoryImpl.java   
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new com.sun.rowset.FilteredRowSetImpl();
}
项目:jdk8u-dev-jdk    文件:RowSetFactoryImpl.java   
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new com.sun.rowset.FilteredRowSetImpl();
}
项目:jdk7-jdk    文件:RowSetFactoryImpl.java   
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new com.sun.rowset.FilteredRowSetImpl();
}
项目:openjdk-source-code-learn    文件:RowSetFactoryImpl.java   
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new com.sun.rowset.FilteredRowSetImpl();
}
项目:OLD-OpenJDK8    文件:RowSetFactoryImpl.java   
public FilteredRowSet createFilteredRowSet() throws SQLException {
    return new com.sun.rowset.FilteredRowSetImpl();
}