use of javax.sql.rowset.CachedRowSet in project spring-framework by spring-projects.
the class SqlRowSetResultSetExtractor method createSqlRowSet.
/**
* Create a SqlRowSet that wraps the given ResultSet,
* representing its data in a disconnected fashion.
* <p>This implementation creates a Spring ResultSetWrappingSqlRowSet
* instance that wraps a standard JDBC CachedRowSet instance.
* Can be overridden to use a different implementation.
* @param rs the original ResultSet (connected)
* @return the disconnected SqlRowSet
* @throws SQLException if thrown by JDBC methods
* @see #newCachedRowSet
* @see org.springframework.jdbc.support.rowset.ResultSetWrappingSqlRowSet
*/
protected SqlRowSet createSqlRowSet(ResultSet rs) throws SQLException {
CachedRowSet rowSet = newCachedRowSet();
rowSet.populate(rs);
return new ResultSetWrappingSqlRowSet(rowSet);
}
use of javax.sql.rowset.CachedRowSet in project jdk8u_jdk by JetBrains.
the class CommonCachedRowSetTests method commonCachedRowSetTest0062.
/*
* Initialize a RowSet via the populate method specifying a starting row.
* Validate it matches the original ResultSet starting for the specofied
* offset
*/
@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();
}
use of javax.sql.rowset.CachedRowSet in project jdk8u_jdk by JetBrains.
the class CommonCachedRowSetTests method commonCachedRowSetTest0061.
/*
* Initialize a RowSet via the populate method. Validate it matches
* the original ResultSet
*/
@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();
}
use of javax.sql.rowset.CachedRowSet in project jdk8u_jdk by JetBrains.
the class JoinRowSetTests method createCachedRowSetsToUse.
/*
* DataProvider used to set parameters for basic types that are supported
*/
@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 } };
}
use of javax.sql.rowset.CachedRowSet in project adempiere by adempiere.
the class CCachedRowSet method getRowSet.
// get
/**
* Get and Execute Row Set.
* No parameters, Read-Only, Scroll Insensitive
* @param sql sql
* @param conn connection
* @param db database
* @return row set
* @throws SQLException
*/
public static RowSet getRowSet(String sql, Connection conn, AdempiereDatabase db) throws SQLException {
if (db.getName().equals(Database.DB_ORACLE)) {
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery(sql);
OracleCachedRowSet crs = new OracleCachedRowSet();
crs.populate(rs);
rs.close();
stmt.close();
return crs;
}
CachedRowSet crs = get();
crs.setConcurrency(ResultSet.CONCUR_READ_ONLY);
crs.setType(ResultSet.TYPE_SCROLL_INSENSITIVE);
crs.setCommand(sql);
crs.execute(conn);
return crs;
}
Aggregations