javax.sql.rowset.CachedRowSet Java Examples
The following examples show how to use
javax.sql.rowset.CachedRowSet.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommonCachedRowSetTests.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@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(); }
Example #2
Source File: CommonCachedRowSetTests.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@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(); }
Example #3
Source File: CommonCachedRowSetTests.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #4
Source File: CommonCachedRowSetTests.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #5
Source File: CommonCachedRowSetTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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} }; }
Example #6
Source File: CommonCachedRowSetTests.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@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(); }
Example #7
Source File: CommonCachedRowSetTests.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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(); }
Example #8
Source File: JoinRowSetTests.java From hottub with GNU General Public License v2.0 | 6 votes |
@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} }; }
Example #9
Source File: CommonCachedRowSetTests.java From hottub with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "rowSetType") public void commonCachedRowSetTest0028(CachedRowSet rs) throws Exception { int rows = 100; rs.setPageSize(rows); assertTrue(rows == rs.getPageSize()); rs.setPageSize(0); assertTrue(rs.getPageSize() == 0); rs.close(); }
Example #10
Source File: CommonCachedRowSetTests.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@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(); }
Example #11
Source File: CommonCachedRowSetTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "rowsetUsingCoffees", enabled = true) public void commonCachedRowSetTest0060(CachedRowSet rs) throws Exception { int rowToUpdate = 2; String coffee = "Hazelnut"; 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(rowToUpdate); String origCoffee = crs1.getString(2); crs1.updateString(2, coffee); assertTrue(crs1.columnUpdated(2)); crs1.updateRow(); assertTrue(crs1.rowUpdated()); assertFalse(origCoffee.equals(crs1.getString(2))); // Restore back to our original state and the // previous value for the column within the row should be there rsl.resetFlag(); crs1.restoreOriginal(); assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); assertTrue(crs1.isBeforeFirst()); // absolute() is failing for some reason so need to look at this later crs1.next(); crs1.next(); assertFalse(crs1.columnUpdated(2)); assertFalse(crs1.rowUpdated()); assertTrue(origCoffee.equals(crs1.getString(2))); } rs.close(); }
Example #12
Source File: CommonCachedRowSetTests.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "rowSetType") public void commonCachedRowSetTest0028(CachedRowSet rs) throws Exception { int rows = 100; rs.setPageSize(rows); assertTrue(rows == rs.getPageSize()); rs.setPageSize(0); assertTrue(rs.getPageSize() == 0); rs.close(); }
Example #13
Source File: CommonRowSetTests.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); }
Example #14
Source File: CommonCachedRowSetTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@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(); }
Example #15
Source File: CommonCachedRowSetTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@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(); }
Example #16
Source File: CommonCachedRowSetTests.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "rowsetUsingCoffeeHouses", expectedExceptions = SQLException.class) public void commonCachedRowSetTest0047(CachedRowSet rs) throws Exception { rs.insertRow(); rs.undoUpdate(); rs.close(); }
Example #17
Source File: CommonCachedRowSetTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0062(CachedRowSet rs) throws Exception { Object[] expectedRows = { 32001, 10042, 10024, 10039, 10041, 33005, 33010, 10035, 10037, 10034, 32004 }; int startingRow = 4; try (CachedRowSet crs1 = rsf.createCachedRowSet()) { rs.beforeFirst(); crs1.populate(rs, startingRow); assertEquals(crs1.size(), COFFEE_HOUSES_ROWS - startingRow + 1); assertEquals(getPrimaryKeys(crs1), expectedRows); } rs.close(); }
Example #18
Source File: CommonCachedRowSetTests.java From hottub with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "rowsetUsingCoffeeHouses", expectedExceptions = SQLException.class) public void commonCachedRowSetTest0023(CachedRowSet rs) throws Exception { String[] expectedColNames = {"COF_ID", "SUP_ID"}; rs.setMatchColumn(expectedColNames); String[] actualColNames = rs.getMatchColumnNames(); assertTrue(actualColNames != null); rs.unsetMatchColumn(expectedColNames); actualColNames = rs.getMatchColumnNames(); rs.close(); }
Example #19
Source File: CommonCachedRowSetTests.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@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(); }
Example #20
Source File: CommonCachedRowSetTests.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@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(); }
Example #21
Source File: CommonCachedRowSetTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "rowsetUsingCoffeeHouses", expectedExceptions = SQLException.class) public void commonCachedRowSetTest0023(CachedRowSet rs) throws Exception { String[] expectedColNames = {"COF_ID", "SUP_ID"}; rs.setMatchColumn(expectedColNames); String[] actualColNames = rs.getMatchColumnNames(); assertTrue(actualColNames != null); rs.unsetMatchColumn(expectedColNames); actualColNames = rs.getMatchColumnNames(); rs.close(); }
Example #22
Source File: CommonCachedRowSetTests.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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); }
Example #23
Source File: JoinRowSetTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "createCachedRowSetsToUse") public void joinRowSetTests0006(CachedRowSet crs, CachedRowSet crs1) throws Exception { try (JoinRowSet jrs = newInstance()) { crs.setMatchColumn(COFFEES_JOIN_COLUMN_INDEX); crs1.setMatchColumn(SUPPLIERS_JOIN_COLUMN_INDEX); jrs.addRowSet(crs); jrs.addRowSet(crs1); validateResults(jrs); crs.close(); crs1.close(); } }
Example #24
Source File: CommonCachedRowSetTests.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@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(); }
Example #25
Source File: SqlRowSetResultSetExtractor.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public CachedRowSet createCachedRowSet() throws SQLException { try { return (CachedRowSet) implementationClass.newInstance(); } catch (Throwable ex) { throw new IllegalStateException(ex); } }
Example #26
Source File: CommonCachedRowSetTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@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(); }
Example #27
Source File: CommonCachedRowSetTests.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "rowsetUsingCoffeeHouses", expectedExceptions = SQLException.class) public void commonCachedRowSetTest0045(CachedRowSet rs) throws Exception { rs.setShowDeleted(true); rs.beforeFirst(); rs.undoDelete(); rs.close(); }
Example #28
Source File: JoinRowSetTests.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "createCachedRowSetsToUse") public void joinRowSetTests0002(CachedRowSet crs, CachedRowSet crs1) throws Exception { try (JoinRowSet jrs = newInstance()) { RowSet[] rowsets = {crs, crs1}; String[] joinCols = {JOIN_COLNAME, JOIN_COLNAME}; jrs.addRowSet(rowsets, joinCols); validateResults(jrs); crs.close(); crs1.close(); } }
Example #29
Source File: JoinRowSetTests.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "createCachedRowSetsToUse") public void joinRowSetTests0005(CachedRowSet crs, CachedRowSet crs1) throws Exception { try (JoinRowSet jrs = newInstance()) { crs.setMatchColumn(JOIN_COLNAME); crs1.setMatchColumn(JOIN_COLNAME); jrs.addRowSet(crs); jrs.addRowSet(crs1); validateResults(jrs); crs.close(); crs1.close(); } }
Example #30
Source File: CommonCachedRowSetTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "rowsetUsingCoffeeHouses") public void commonCachedRowSetTest0061(CachedRowSet rs) throws Exception { try (CachedRowSet crs1 = rsf.createCachedRowSet()) { rs.beforeFirst(); crs1.populate(rs); compareRowSets(rs, crs1); } rs.close(); }