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


Java CachedRowSet类代码示例

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


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

示例1: commonCachedRowSetTest0059

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
@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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:CommonCachedRowSetTests.java

示例2: commonCachedRowSetTest0026

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
@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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:CommonCachedRowSetTests.java

示例3: rowsetUsingDataTypes

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
@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}
    };
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:CommonCachedRowSetTests.java

示例4: compareRowSets

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
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);
            }
        }

    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:CommonCachedRowSetTests.java

示例5: commonCachedRowSetTest0053

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
@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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:CommonCachedRowSetTests.java

示例6: commonCachedRowSetTest0008

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
@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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:CommonCachedRowSetTests.java

示例7: createCachedRowSetsToUse

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
@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}
    };
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:JoinRowSetTests.java

示例8: commonCachedRowSetTest0051

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
@Test(dataProvider = "rowsetUsingCoffeeHouses",
        expectedExceptions = SQLException.class)
public void commonCachedRowSetTest0051(CachedRowSet rs) throws Exception {
    rs.setShowDeleted(true);
    rs.beforeFirst();
    rs.undoInsert();
    rs.close();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:CommonCachedRowSetTests.java

示例9: createCachedRowSet

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
@Override
public CachedRowSet createCachedRowSet() throws SQLException {
	try {
		return (CachedRowSet) implementationClass.newInstance();
	}
	catch (Throwable ex) {
		throw new IllegalStateException(ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:SqlRowSetResultSetExtractor.java

示例10: commonCachedRowSetTest0047

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
@Test(dataProvider = "rowsetUsingCoffeeHouses",
        expectedExceptions = SQLException.class)
public void commonCachedRowSetTest0047(CachedRowSet rs) throws Exception {
    rs.insertRow();
    rs.undoUpdate();
    rs.close();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:CommonCachedRowSetTests.java

示例11: createCoffeesRowSet

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:CommonRowSetTests.java

示例12: commonCachedRowSetTest0037

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
@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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:CommonCachedRowSetTests.java

示例13: initCoffeeHousesMetaData

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
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);

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:CommonRowSetTests.java

示例14: createDataTypesRowSet

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:CommonCachedRowSetTests.java

示例15: initDataTypesMetaData

import javax.sql.rowset.CachedRowSet; //导入依赖的package包/类
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);

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:32,代码来源:CommonCachedRowSetTests.java


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