本文整理匯總了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();
}
示例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();
}
示例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}
};
}
示例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);
}
}
}
示例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();
}
示例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();
}
示例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}
};
}
示例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();
}
示例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);
}
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}