Search in sources :

Example 1 with CachedRowSet

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);
}
Also used : ResultSetWrappingSqlRowSet(org.springframework.jdbc.support.rowset.ResultSetWrappingSqlRowSet) CachedRowSet(javax.sql.rowset.CachedRowSet)

Example 2 with CachedRowSet

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();
}
Also used : CachedRowSet(javax.sql.rowset.CachedRowSet) Test(org.testng.annotations.Test)

Example 3 with CachedRowSet

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();
}
Also used : CachedRowSet(javax.sql.rowset.CachedRowSet) Test(org.testng.annotations.Test)

Example 4 with CachedRowSet

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 } };
}
Also used : CachedRowSet(javax.sql.rowset.CachedRowSet) DataProvider(org.testng.annotations.DataProvider)

Example 5 with CachedRowSet

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;
}
Also used : OracleCachedRowSet(oracle.jdbc.rowset.OracleCachedRowSet) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) OracleCachedRowSet(oracle.jdbc.rowset.OracleCachedRowSet) CachedRowSet(javax.sql.rowset.CachedRowSet)

Aggregations

CachedRowSet (javax.sql.rowset.CachedRowSet)16 Test (org.testng.annotations.Test)11 OracleCachedRowSet (oracle.jdbc.rowset.OracleCachedRowSet)3 TestRowSetListener (util.TestRowSetListener)3 SQLException (java.sql.SQLException)2 RowSet (javax.sql.RowSet)2 JoinRowSet (javax.sql.rowset.JoinRowSet)2 WebRowSet (javax.sql.rowset.WebRowSet)2 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 ResultSetWrappingSqlRowSet (org.springframework.jdbc.support.rowset.ResultSetWrappingSqlRowSet)1 DataProvider (org.testng.annotations.DataProvider)1