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

项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0026(CachedRowSet rs) throws Exception {
    Object[] afterDelete = {
        10023, 33002, 10040, 32001, 10042, 10024, 10039, 10041,
        33005, 33010, 10037, 10034, 32004
    };
    int rowToDelete = 10035;
    // All rows should be found
    assertEquals(getPrimaryKeys(rs), COFFEE_HOUSES_PRIMARY_KEYS);
    // Delete the row
    assertTrue(deleteRowByPrimaryKey(rs, rowToDelete, 1));
    // With setShowDeleted(false) which is the default,
    // the deleted row should not be visible
    assertFalse(findRowByPrimaryKey(rs, rowToDelete, 1));
    assertEquals(getPrimaryKeys(rs), afterDelete);
    assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
    // With setShowDeleted(true), the deleted row should be visible
    rs.setShowDeleted(true);
    assertTrue(findRowByPrimaryKey(rs, rowToDelete, 1));
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs, JDBCType.INTEGER},
        {rs, JDBCType.CHAR},
        {rs, JDBCType.VARCHAR},
        {rs, JDBCType.BIGINT},
        {rs, JDBCType.BOOLEAN},
        {rs, JDBCType.SMALLINT},
        {rs, JDBCType.DOUBLE},
        {rs, JDBCType.DECIMAL},
        {rs, JDBCType.REAL},
        {rs, JDBCType.TINYINT},
        {rs, JDBCType.DATE},
        {rs, JDBCType.TIME},
        {rs, JDBCType.TIMESTAMP},
        {rs, JDBCType.VARBINARY},
        {rs, JDBCType.ARRAY},
        {rs, JDBCType.REF},
        {rs, JDBCType.FLOAT}
    };
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs, JDBCType.INTEGER},
        {rs, JDBCType.CHAR},
        {rs, JDBCType.VARCHAR},
        {rs, JDBCType.BIGINT},
        {rs, JDBCType.BOOLEAN},
        {rs, JDBCType.SMALLINT},
        {rs, JDBCType.DOUBLE},
        {rs, JDBCType.DECIMAL},
        {rs, JDBCType.REAL},
        {rs, JDBCType.TINYINT},
        {rs, JDBCType.DATE},
        {rs, JDBCType.TIME},
        {rs, JDBCType.TIMESTAMP},
        {rs, JDBCType.VARBINARY},
        {rs, JDBCType.ARRAY},
        {rs, JDBCType.REF},
        {rs, JDBCType.FLOAT}
    };
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
private void compareRowSets(CachedRowSet crs, CachedRowSet crs1) throws Exception {

        int rows = crs.size();
        assertTrue(rows == crs1.size());

        ResultSetMetaData rsmd = crs.getMetaData();

        compareMetaData(rsmd, crs1.getMetaData());
        int cols = rsmd.getColumnCount();

        for (int row = 1; row <= rows; row++) {
            crs.absolute((row));
            crs1.absolute(row);
            for (int col = 1; col <= cols; col++) {
                compareColumnValue(JDBCType.valueOf(rsmd.getColumnType(col)),
                        crs, crs1, col);
            }
        }

    }
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0026(CachedRowSet rs) throws Exception {
    Object[] afterDelete = {
        10023, 33002, 10040, 32001, 10042, 10024, 10039, 10041,
        33005, 33010, 10037, 10034, 32004
    };
    int rowToDelete = 10035;
    // All rows should be found
    assertEquals(getPrimaryKeys(rs), COFFEE_HOUSES_PRIMARY_KEYS);
    // Delete the row
    assertTrue(deleteRowByPrimaryKey(rs, rowToDelete, 1));
    // With setShowDeleted(false) which is the default,
    // the deleted row should not be visible
    assertFalse(findRowByPrimaryKey(rs, rowToDelete, 1));
    assertEquals(getPrimaryKeys(rs), afterDelete);
    assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
    // With setShowDeleted(true), the deleted row should be visible
    rs.setShowDeleted(true);
    assertTrue(findRowByPrimaryKey(rs, rowToDelete, 1));
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0053(CachedRowSet rs) throws Exception {
    int rowToInsert = 1961;
    assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
    // Add new row
    rs.moveToInsertRow();
    rs.updateInt(1, rowToInsert);
    rs.updateString(2, "GOTHAM");
    rs.updateInt(3, 3450);
    rs.updateInt(4, 2005);
    rs.updateInt(5, 5455);
    rs.insertRow();
    rs.moveToCurrentRow();
    // check that the number of rows has increased
    assertTrue(rs.size() == COFFEE_HOUSES_ROWS + 1);
    assertTrue(findRowByPrimaryKey(rs, rowToInsert, 1));
    rs.undoInsert();
    // Check to make sure the row is no longer there
    assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
    assertFalse(findRowByPrimaryKey(rs, rowToInsert, 1));
    rs.close();
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0008(CachedRowSet rs) throws Exception {
    TestRowSetListener rsl = new TestRowSetListener();
    rs.addRowSetListener(rsl);

    rs.first();
    assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED));
    rs.deleteRow();
    assertTrue(
            rsl.isNotified(TestRowSetListener.ROW_CHANGED | TestRowSetListener.CURSOR_MOVED));
    rsl.resetFlag();
    rs.setShowDeleted(true);
    rs.undoDelete();
    assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED));
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffees", enabled = true)
public void commonCachedRowSetTest0059(CachedRowSet rs) throws Exception {
    int rowToDelete = 2;
    try (CachedRowSet crs1 = rsf.createCachedRowSet()) {
        rs.beforeFirst();
        crs1.populate(rs);
        TestRowSetListener rsl = new TestRowSetListener();
        crs1.addRowSetListener(rsl);
        // Delete a row, the PK is also the absolute position as a List
        // backs the RowSet
        crs1.absolute(rowToDelete);
        crs1.deleteRow();
        assertTrue(crs1.rowDeleted());
        assertFalse(findRowByPrimaryKey(crs1, rowToDelete, 1));
        // Restore back to our original state and the
        // previously deleted row should be there
        rsl.resetFlag();
        crs1.restoreOriginal();
        assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
        assertTrue(crs1.isBeforeFirst());
        crs1.absolute(rowToDelete);
        assertFalse(crs1.rowDeleted());
        assertTrue(findRowByPrimaryKey(crs1, rowToDelete, 1));
    }
    rs.close();
}
项目:jdk8u-jdk    文件:JoinRowSetTests.java   
@DataProvider(name = "createCachedRowSetsToUse")
private Object[][] createCachedRowSetsToUse() throws SQLException {
    CachedRowSet crs = rsf.createCachedRowSet();
    initCoffeesMetaData(crs);
    createCoffeesRows(crs);
    // Make sure you are not on the insertRow
    crs.moveToCurrentRow();
    CachedRowSet crs1 = rsf.createCachedRowSet();
    initSuppliersMetaData(crs1);
    createSuppiersRows(crs1);
    // Make sure you are not on the insertRow
    crs1.moveToCurrentRow();
    return new Object[][]{
        {crs, crs1}
    };
}
项目:openjdk-jdk10    文件:JoinRowSetTests.java   
@DataProvider(name = "createCachedRowSetsToUse")
private Object[][] createCachedRowSetsToUse() throws SQLException {
    CachedRowSet crs = rsf.createCachedRowSet();
    initCoffeesMetaData(crs);
    createCoffeesRows(crs);
    // Make sure you are not on the insertRow
    crs.moveToCurrentRow();
    CachedRowSet crs1 = rsf.createCachedRowSet();
    initSuppliersMetaData(crs1);
    createSuppiersRows(crs1);
    // Make sure you are not on the insertRow
    crs1.moveToCurrentRow();
    return new Object[][]{
        {crs, crs1}
    };
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffees", enabled = true)
public void commonCachedRowSetTest0059(CachedRowSet rs) throws Exception {
    int rowToDelete = 2;
    try (CachedRowSet crs1 = rsf.createCachedRowSet()) {
        rs.beforeFirst();
        crs1.populate(rs);
        TestRowSetListener rsl = new TestRowSetListener();
        crs1.addRowSetListener(rsl);
        // Delete a row, the PK is also the absolute position as a List
        // backs the RowSet
        crs1.absolute(rowToDelete);
        crs1.deleteRow();
        assertTrue(crs1.rowDeleted());
        assertFalse(findRowByPrimaryKey(crs1, rowToDelete, 1));
        // Restore back to our original state and the
        // previously deleted row should be there
        rsl.resetFlag();
        crs1.restoreOriginal();
        assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
        assertTrue(crs1.isBeforeFirst());
        crs1.absolute(rowToDelete);
        assertFalse(crs1.rowDeleted());
        assertTrue(findRowByPrimaryKey(crs1, rowToDelete, 1));
    }
    rs.close();
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses",
        expectedExceptions = SQLException.class)
public void commonCachedRowSetTest0051(CachedRowSet rs) throws Exception {
    rs.setShowDeleted(true);
    rs.beforeFirst();
    rs.undoInsert();
    rs.close();
}
项目:lams    文件:SqlRowSetResultSetExtractor.java   
@Override
public CachedRowSet createCachedRowSet() throws SQLException {
    try {
        return (CachedRowSet) implementationClass.newInstance();
    }
    catch (Throwable ex) {
        throw new IllegalStateException(ex);
    }
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses",
        expectedExceptions = SQLException.class)
public void commonCachedRowSetTest0047(CachedRowSet rs) throws Exception {
    rs.insertRow();
    rs.undoUpdate();
    rs.close();
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
protected <T extends RowSet> T createCoffeesRowSet() throws SQLException {
    T rs = (T) newInstance();
    initCoffeesMetaData((CachedRowSet) rs);
    createCoffeesRows(rs);
    // Make sure you are not on the insertRow
    rs.moveToCurrentRow();
    return rs;
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0037(CachedRowSet rs) throws Exception {
    try (CachedRowSet crs1 = rs.createCopySchema()) {
        assertTrue(crs1.size() == 0);
        compareMetaData(crs1.getMetaData(), rs.getMetaData());
    }
    rs.close();
}
项目:jdk8u-jdk    文件:CommonRowSetTests.java   
protected <T extends RowSet> T createCoffeesRowSet() throws SQLException {
    T rs = (T) newInstance();
    initCoffeesMetaData((CachedRowSet) rs);
    createCoffeesRows(rs);
    // Make sure you are not on the insertRow
    rs.moveToCurrentRow();
    return rs;
}
项目:jdk8u-jdk    文件:CommonRowSetTests.java   
private void initCoffeeHousesMetaData(CachedRowSet crs) throws SQLException {
    RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl();
    crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE);

    /*
     *  CREATE TABLE COFFEE_HOUSES(
     *   STORE_ID Integer NOT NULL,
     *   CITY VARCHAR(32),
     *   COFFEE INTEGER NOT NULL,
     *   MERCH INTEGER NOT NULL,
     *   TOTAL INTEGER NOT NULL,
     *   PRIMARY KEY (STORE_ID))
     */
    rsmd.setColumnCount(COFFEE_HOUSES_COLUMN_NAMES.length);
    for(int i = 1; i <= COFFEE_HOUSES_COLUMN_NAMES.length; i++){
        rsmd.setColumnName(i, COFFEE_HOUSES_COLUMN_NAMES[i-1]);
        rsmd.setColumnLabel(i, rsmd.getColumnName(i));
    }

    rsmd.setColumnType(1, Types.INTEGER);
    rsmd.setColumnType(2, Types.VARCHAR);
    rsmd.setColumnType(3, Types.INTEGER);
    rsmd.setColumnType(4, Types.INTEGER);
    rsmd.setColumnType(5, Types.INTEGER);
    crs.setMetaData(rsmd);
    crs.setTableName(COFFEE_HOUSES_TABLE);

}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
protected <T extends RowSet> T createDataTypesRowSet() throws SQLException {
    T rs = (T) newInstance();
    initDataTypesMetaData((CachedRowSet) rs);
    createDataTypesRows(rs);
    // Make sure you are not on the insertRow
    rs.moveToCurrentRow();
    return rs;
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
protected void initDataTypesMetaData(CachedRowSet crs) throws SQLException {
    RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl();
    crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE);

    rsmd.setColumnCount(DATATYPES_COLUMN_NAMES.length);

    for (int i = 1; i <= DATATYPES_COLUMN_NAMES.length; i++) {
        rsmd.setColumnName(i, DATATYPES_COLUMN_NAMES[i - 1]);
        rsmd.setColumnLabel(i, rsmd.getColumnName(i));
    }

    rsmd.setColumnType(1, Types.INTEGER);
    rsmd.setColumnType(2, Types.CHAR);
    rsmd.setColumnType(3, Types.VARCHAR);
    rsmd.setColumnType(4, Types.BIGINT);
    rsmd.setColumnType(5, Types.BOOLEAN);
    rsmd.setColumnType(6, Types.SMALLINT);
    rsmd.setColumnType(7, Types.DOUBLE);
    rsmd.setColumnType(8, Types.DECIMAL);
    rsmd.setColumnType(9, Types.REAL);
    rsmd.setColumnType(10, Types.TINYINT);
    rsmd.setColumnType(11, Types.DATE);
    rsmd.setColumnType(12, Types.TIME);
    rsmd.setColumnType(13, Types.TIMESTAMP);
    rsmd.setColumnType(14, Types.VARBINARY);
    rsmd.setColumnType(15, Types.ARRAY);
    rsmd.setColumnType(16, Types.REF);
    rsmd.setColumnType(17, Types.FLOAT);
    crs.setMetaData(rsmd);

}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
protected void initCoffeesMetaData(CachedRowSet crs) throws SQLException {
    RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl();
    crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE);

    /*
     *  CREATE TABLE COFFEES (
     *   COF_ID INTEGER NOT NULL,
     *   COF_NAME VARCHAR(32) NOT NULL,
     *   SUP_ID INTEGER NOT NULL,
     *   PRICE NUMBERIC(10,2 NOT NULL,
     *   SALES INTEGER NOT NULL,
     *   TOTAL INTEGER NOT NULL,
     *   PRIMARY KEY (COF_ID),
     *   FOREIGN KEY (SUP_ID) REFERENCES SUPPLIERS (SUP_ID) )
     */
    rsmd.setColumnCount(COFFEES_COLUMN_NAMES.length);
    for(int i = 1; i <= COFFEES_COLUMN_NAMES.length; i++){
        rsmd.setColumnName(i, COFFEES_COLUMN_NAMES[i-1]);
        rsmd.setColumnLabel(i, rsmd.getColumnName(i));
    }

    rsmd.setColumnType(1, Types.INTEGER);
    rsmd.setColumnType(2, Types.VARCHAR);
    rsmd.setColumnType(3, Types.INTEGER);
    rsmd.setColumnType(4, Types.NUMERIC);
    rsmd.setPrecision(4, 10);
    rsmd.setScale(4, 2);
    rsmd.setColumnType(5, Types.INTEGER);
    rsmd.setColumnType(6, Types.INTEGER);
    crs.setMetaData(rsmd);
    crs.setTableName(COFFEES_TABLE);

}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void commonCachedRowSetTest0004(CachedRowSet rs) throws Exception {
    TestRowSetListener rsl = new TestRowSetListener();
    rs.addRowSetListener(rsl);
    rs.release();
    assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void commonCachedRowSetTest0005(CachedRowSet rs) throws Exception {
    TestRowSetListener rsl = new TestRowSetListener();
    rs.addRowSetListener(rsl);
    rs.restoreOriginal();
    assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
    rs.close();
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses",
        expectedExceptions = SQLException.class)
public void commonCachedRowSetTest0049(CachedRowSet rs) throws Exception {
    rs.setShowDeleted(true);
    rs.afterLast();
    rs.undoUpdate();
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void commonCachedRowSetTest0010(CachedRowSet rs) throws Exception {
    assertNull(rs.getTableName());
    rs.setTableName(COFFEE_HOUSES_TABLE);
    assertTrue(rs.getTableName().equals(COFFEE_HOUSES_TABLE));
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void commonCachedRowSetTest0011(CachedRowSet rs) throws Exception {
    int[] pkeys = {1, 3};
    assertNull(rs.getKeyColumns());
    rs.setKeyColumns(pkeys);
    assertEquals(rs.getKeyColumns(), pkeys);
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses",
        expectedExceptions = SQLException.class)
public void commonCachedRowSetTest0013(CachedRowSet rs) throws Exception {
    int[] cols = {1, -1};
    rs.setMatchColumn(cols);
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false)
public void commonCachedRowSetTest0016(CachedRowSet rs) throws Exception {
    int[] expectedCols = {1};
    String[] expectedColNames = {"ID"};
    rs.setMatchColumn(1);
    int[] actualCols = rs.getMatchColumnIndexes();
    String[] actualColNames = rs.getMatchColumnNames();
    for (int i = 0; i < actualCols.length; i++) {
        System.out.println(actualCols[i]);
    }
    assertEquals(actualCols, expectedCols);
    assertEquals(actualColNames, expectedColNames);
    rs.close();
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void commonCachedRowSetTest0003(CachedRowSet rs) throws SQLException {

    // Register a provider and make sure it is avaiable
    SyncFactory.registerProvider(stubProvider);
    rs.setSyncProvider(stubProvider);
    SyncProvider sp = rs.getSyncProvider();
    assertTrue(sp instanceof StubSyncProvider);
    SyncFactory.unregisterProvider(stubProvider);
    rs.close();
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffees")
public void commonCachedRowSetTest0056(CachedRowSet rs) throws Exception {
    String coffee = "Hazelnut";
    int sales = 100;
    int id = 200;
    Object[] updatedPkeys = {1, id, 3, 4, 5};
    // Change the coffee name and sales total for row 2 and save the
    // previous values
    rs.absolute(2);
    int origId = rs.getInt(1);
    String origCoffee = rs.getString(2);
    int origSales = rs.getInt(5);
    rs.updateInt(1, id);
    rs.updateString(2, coffee);
    rs.updateInt(5, sales);
    // MetaData should match
    try ( // Get the original original RowSet and validate that the changes
            // are only made to the current, not the original
            ResultSet rs1 = rs.getOriginal()) {
        // MetaData should match
        compareMetaData(rs.getMetaData(), rs1.getMetaData());
        assertTrue(rs1.isBeforeFirst());
        assertTrue(rs1.getConcurrency() == ResultSet.CONCUR_UPDATABLE);
        assertTrue(rs1.getType() == ResultSet.TYPE_SCROLL_INSENSITIVE);
        rs1.absolute(2);
        // Check original rowset is not changed
        assertTrue(rs1.getInt(1) == origId);
        assertTrue(rs1.getString(2).equals(origCoffee));
        assertTrue(rs1.getInt(5) == origSales);
        assertEquals(getPrimaryKeys(rs1), COFFEES_PRIMARY_KEYS);
        // Check current rowset
        assertTrue(rs.getInt(1) == id);
        assertTrue(rs.getString(2).equals(coffee));
        assertTrue(rs.getInt(5) == sales);
        assertEquals(getPrimaryKeys(rs), updatedPkeys);
    }
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false)
public void commonCachedRowSetTest0019(CachedRowSet rs) throws Exception {
    int[] expectedCols = {1, 3};
    String[] expectedColNames = {"COF_ID", "SUP_ID"};
    rs.setMatchColumn(expectedColNames);
    int[] actualCols = rs.getMatchColumnIndexes();
    String[] actualColNames = rs.getMatchColumnNames();
    assertEquals(actualCols, expectedCols);
    assertEquals(actualColNames, expectedColNames);
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses",
        expectedExceptions = SQLException.class)
public void commonCachedRowSetTest0020(CachedRowSet rs) throws Exception {
    rs.setMatchColumn(1);
    int[] actualCols = rs.getMatchColumnIndexes();
    assertTrue(actualCols != null);
    rs.unsetMatchColumn(1);
    actualCols = rs.getMatchColumnIndexes();
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses",
        expectedExceptions = SQLException.class)
public void commonCachedRowSetTest0021(CachedRowSet rs) throws Exception {
    String matchColumn = "ID";
    rs.setMatchColumn(matchColumn);
    String[] actualColNames = rs.getMatchColumnNames();
    assertTrue(actualColNames != null);
    rs.unsetMatchColumn(matchColumn);
    actualColNames = rs.getMatchColumnNames();
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses",
        expectedExceptions = SQLException.class)
public void commonCachedRowSetTest0022(CachedRowSet rs) throws Exception {
    int[] expectedCols = {1, 3};
    rs.setMatchColumn(expectedCols);
    int[] actualCols = rs.getMatchColumnIndexes();
    assertTrue(actualCols != null);
    rs.unsetMatchColumn(expectedCols);
    actualCols = rs.getMatchColumnIndexes();
    rs.close();
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
protected <T extends RowSet> T createCoffeeHousesRowSet() throws SQLException {
    T rs = (T) newInstance();
    initCoffeeHousesMetaData((CachedRowSet) rs);
    createCoffeeHouseRows(rs);
    // Make sure you are not on the insertRow
    rs.moveToCurrentRow();
    return rs;
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0036(CachedRowSet rs) throws Exception {
    try (CachedRowSet crs1 = rs.createCopy()) {
        compareRowSets(rs, crs1);
    }
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0034(CachedRowSet rs) throws Exception {
    Object[] cities = {"Mendocino", "Seattle", "SF", "Portland", "SF",
        "Sacramento", "Carmel", "LA", "Olympia", "Seattle", "SF",
        "LA", "San Jose", "Eugene"};
    rs.beforeFirst();
    assertEquals(rs.toCollection(2).toArray(), cities);
    assertEquals(rs.toCollection("CITY").toArray(), cities);
    rs.close();
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0055(CachedRowSet rs) throws Exception {
    int rowToInsert = 1961;
    assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
    // Add new row
    rs.moveToInsertRow();
    rs.updateInt(1, rowToInsert);
    rs.updateString(2, "GOTHAM");
    rs.updateInt(3, 3450);
    rs.updateInt(4, 2005);
    rs.updateInt(5, 5455);
    rs.insertRow();
    rs.moveToCurrentRow();
    // check that the number of rows has increased
    assertTrue(rs.size() == COFFEE_HOUSES_ROWS + 1);
    assertTrue(findRowByPrimaryKey(rs, rowToInsert, 1));
    rs.absolute(COFFEE_HOUSES_ROWS + 1);
    // Save off the original column values
    String f2 = rs.getString(2);
    int f3 = rs.getInt(3);
    rs.updateString(2, "SMALLVILLE");
    rs.updateInt(3, 500);
    // Validate the columns have been updated
    assertTrue(rs.columnUpdated(2));
    assertTrue(rs.columnUpdated(3));
    // Undo the update and validate it has taken place
    rs.absolute(COFFEE_HOUSES_ROWS + 1);
    rs.undoUpdate();
    assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
    assertFalse(findRowByPrimaryKey(rs, rowToInsert, 1));
    rs.close();
}
项目:openjdk-jdk10    文件:JoinRowSetTests.java   
@Test(dataProvider = "createCachedRowSetsToUse")
public void joinRowSetTests0000(CachedRowSet crs, CachedRowSet crs1)
        throws Exception {

    try (JoinRowSet jrs = newInstance()) {
        jrs.addRowSet(crs, JOIN_COLNAME);
        jrs.addRowSet(crs1, JOIN_COLNAME);
        validateResults(jrs);
        crs.close();
        crs1.close();
    }
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false)
public void commonCachedRowSetTest0017(CachedRowSet rs) throws Exception {
    int[] expectedCols = {1};
    String[] expectedColNames = {"ID"};
    rs.setMatchColumn(expectedColNames[0]);
    int[] actualCols = rs.getMatchColumnIndexes();
    String[] actualColNames = rs.getMatchColumnNames();
    assertEquals(actualCols, expectedCols);
    assertEquals(actualColNames, expectedColNames);
    rs.close();
}