Java 类javax.sql.RowSet 实例源码

项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0043(RowSet rs) throws Exception {
    assertFalse(rs.isAfterLast());
    assertFalse(rs.isLast());
    rs.afterLast();
    assertTrue(rs.isAfterLast());
    assertFalse(rs.isLast());
    rs.previous();
    assertFalse(rs.isAfterLast());
    assertTrue(rs.isLast());
    rs.previous();
    assertFalse(rs.isAfterLast());
    assertFalse(rs.isLast());
    rs.last();
    assertFalse(rs.isAfterLast());
    assertTrue(rs.isLast());
    rs.close();
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0007(RowSet rs) throws Exception {
    TestRowSetListener rsl = new TestRowSetListener();
    TestRowSetListener rsl2 = new TestRowSetListener();
    rs.addRowSetListener(rsl);
    rs.addRowSetListener(rsl2);
    rs.first();
    rs.updateInt(1, 1961);
    rs.updateString(2, "Pittsburgh");
    rs.updateInt(3, 1987);
    rs.updateInt(4, 2341);
    rs.updateInt(5, 6689);
    rs.updateRow();
    assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED
            | TestRowSetListener.ROW_CHANGED));
    assertTrue(rsl2.isNotified(TestRowSetListener.CURSOR_MOVED
            | TestRowSetListener.ROW_CHANGED));
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0042(RowSet rs) throws Exception {
    assertFalse(rs.isBeforeFirst());
    assertFalse(rs.isFirst());
    rs.beforeFirst();
    assertTrue(rs.isBeforeFirst());
    assertFalse(rs.isFirst());
    rs.next();
    assertFalse(rs.isBeforeFirst());
    assertTrue(rs.isFirst());
    rs.next();
    assertFalse(rs.isBeforeFirst());
    assertFalse(rs.isFirst());
    rs.first();
    assertFalse(rs.isBeforeFirst());
    assertTrue(rs.isFirst());
    rs.close();
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0043(RowSet rs) throws Exception {
    assertFalse(rs.isAfterLast());
    assertFalse(rs.isLast());
    rs.afterLast();
    assertTrue(rs.isAfterLast());
    assertFalse(rs.isLast());
    rs.previous();
    assertFalse(rs.isAfterLast());
    assertTrue(rs.isLast());
    rs.previous();
    assertFalse(rs.isAfterLast());
    assertFalse(rs.isLast());
    rs.last();
    assertFalse(rs.isAfterLast());
    assertTrue(rs.isLast());
    rs.close();
}
项目:the-vigilantes    文件:CachedRowsetTest.java   
/**
 * Tests fix for BUG#5188, CachedRowSet errors using PreparedStatement. Uses
 * Sun's "com.sun.rowset.CachedRowSetImpl"
 * 
 * @throws Exception
 */
public void testBug5188() throws Exception {
    String implClass = "com.sun.rowset.CachedRowSetImpl";
    Class<?> c;
    Method populate;
    try {
        c = Class.forName(implClass);
    } catch (ClassNotFoundException e) {
        System.out.println("skipping testBug5188. Requires: " + implClass);
        return;
    }
    populate = c.getMethod("populate", new Class[] { ResultSet.class });

    createTable("testBug5188", "(ID int NOT NULL AUTO_INCREMENT, datafield VARCHAR(64), PRIMARY KEY(ID))");

    this.stmt.executeUpdate("INSERT INTO testBug5188(datafield) values('test data stuff !')");

    String sql = "SELECT * FROM testBug5188 where ID = ?";
    this.pstmt = this.conn.prepareStatement(sql);
    this.pstmt.setString(1, "1");
    this.rs = this.pstmt.executeQuery();

    // create a CachedRowSet and populate it
    RowSet cachedRowSet = (RowSet) c.newInstance();
    // cachedRowSet.populate(rs);
    populate.invoke(cachedRowSet, new Object[] { this.rs });

    // scroll through CachedRowSet ...
    assertTrue(cachedRowSet.next());
    assertEquals("1", cachedRowSet.getString("ID"));
    assertEquals("test data stuff !", cachedRowSet.getString("datafield"));
    assertFalse(cachedRowSet.next());

}
项目:ProyectoPacientes    文件:CachedRowsetTest.java   
/**
 * Tests fix for BUG#5188, CachedRowSet errors using PreparedStatement. Uses
 * Sun's "com.sun.rowset.CachedRowSetImpl"
 * 
 * @throws Exception
 */
public void testBug5188() throws Exception {
    String implClass = "com.sun.rowset.CachedRowSetImpl";
    Class<?> c;
    Method populate;
    try {
        c = Class.forName(implClass);
    } catch (ClassNotFoundException e) {
        System.out.println("skipping testBug5188. Requires: " + implClass);
        return;
    }
    populate = c.getMethod("populate", new Class[] { ResultSet.class });

    createTable("testBug5188", "(ID int NOT NULL AUTO_INCREMENT, datafield VARCHAR(64), PRIMARY KEY(ID))");

    this.stmt.executeUpdate("INSERT INTO testBug5188(datafield) values('test data stuff !')");

    String sql = "SELECT * FROM testBug5188 where ID = ?";
    this.pstmt = this.conn.prepareStatement(sql);
    this.pstmt.setString(1, "1");
    this.rs = this.pstmt.executeQuery();

    // create a CachedRowSet and populate it
    RowSet cachedRowSet = (RowSet) c.newInstance();
    // cachedRowSet.populate(rs);
    populate.invoke(cachedRowSet, new Object[] { this.rs });

    // scroll through CachedRowSet ...
    assertTrue(cachedRowSet.next());
    assertEquals("1", cachedRowSet.getString("ID"));
    assertEquals("test data stuff !", cachedRowSet.getString("datafield"));
    assertFalse(cachedRowSet.next());

}
项目:jdk8u-jdk    文件:CityFilter.java   
public boolean evaluate(RowSet rs) {

        boolean result = false;

        if (rs == null) {
            return false;
        }

        try {
            for (String city : cities) {

                String val = "";
                if (colNumber > 0) {
                    val = (String) rs.getObject(colNumber);
                } else if (colName != null) {
                    val = (String) rs.getObject(colName);
                }

                if (val.equalsIgnoreCase(city)) {
                    return true;
                }
            }
        } catch (SQLException e) {
            result = false;
        }
        return result;
    }
项目:jdk8u-jdk    文件:CommonRowSetTests.java   
@DataProvider(name = "rowSetScrollTypes")
protected Object[][] rowSetScrollTypes() throws Exception {
    RowSet rs = newInstance();

    return new Object[][]{
        {rs, ResultSet.TYPE_FORWARD_ONLY},
        {rs, ResultSet.TYPE_SCROLL_INSENSITIVE},
        {rs, ResultSet.TYPE_SCROLL_SENSITIVE}
    };
}
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@DataProvider(name = "rowsetUsingCoffeeHouses")
protected Object[][] rowsetUsingCoffeeHouses() throws Exception {
    RowSet rs = createCoffeeHousesRowSet();
    return new Object[][]{
        {rs}
    };
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
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);

}
项目:jdk8u-jdk    文件:CommonRowSetTests.java   
protected <T extends RowSet> T createCoffeeHousesRowSet() throws SQLException {
    T rs = (T) newInstance();
    initCoffeeHousesMetaData((CachedRowSet) rs);
    createCoffeeHouseRows(rs);
    // Make sure you are not on the insertRow
    rs.moveToCurrentRow();
    return rs;
}
项目:jdk8u-jdk    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void commonRowSetTest0006(RowSet rs) throws Exception {
    rs.setUrl(url);
    rs.setDataSourceName(dsName);
    assertTrue(rs.getDataSourceName().equals(dsName));
    assertNull(rs.getUrl());
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
protected void createDataTypesRows(RowSet crs) throws SQLException {

        Integer aInteger = 100;
        String aChar = "Oswald Cobblepot";
        Long aLong = Long.MAX_VALUE;
        Short aShort = Short.MAX_VALUE;
        Double aDouble = Double.MAX_VALUE;
        BigDecimal aBigDecimal = BigDecimal.ONE;
        Boolean aBoolean = false;
        Float aFloat = Float.MAX_VALUE;
        Byte aByte = Byte.MAX_VALUE;
        Date aDate = Date.valueOf(LocalDate.now());
        Time aTime = Time.valueOf(LocalTime.now());
        Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now());
        Array aArray = new StubArray("INTEGER", new Object[1]);
        Ref aRef = new SerialRef(new StubRef("INTEGER", query));
        byte[] bytes = new byte[10];
        crs.moveToInsertRow();
        crs.updateInt(1, aInteger);
        crs.updateString(2, aChar);
        crs.updateString(3, aChar);
        crs.updateLong(4, aLong);
        crs.updateBoolean(5, aBoolean);
        crs.updateShort(6, aShort);
        crs.updateDouble(7, aDouble);
        crs.updateBigDecimal(8, aBigDecimal);
        crs.updateFloat(9, aFloat);
        crs.updateByte(10, aByte);
        crs.updateDate(11, aDate);
        crs.updateTime(12, aTime);
        crs.updateTimestamp(13, aTimeStamp);
        crs.updateBytes(14, bytes);
        crs.updateArray(15, aArray);
        crs.updateRef(16, aRef);
        crs.updateDouble(17, aDouble);
        crs.insertRow();
        crs.moveToCurrentRow();

    }
项目:jdk8u-jdk    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void commonRowSetTest0017(RowSet rs) throws Exception {
    rs.setMaxFieldSize(0);
    assertTrue(rs.getMaxFieldSize() == 0);
    rs.setMaxFieldSize(100);
    assertTrue(rs.getMaxFieldSize() == 100);
    rs.setMaxFieldSize(50);
    assertTrue(rs.getMaxFieldSize() == 50);
}
项目:openjdk-jdk10    文件:CityFilter.java   
public boolean evaluate(RowSet rs) {

        boolean result = false;

        if (rs == null) {
            return false;
        }

        try {
            for (String city : cities) {

                String val = "";
                if (colNumber > 0) {
                    val = (String) rs.getObject(colNumber);
                } else if (colName != null) {
                    val = (String) rs.getObject(colName);
                }

                if (val.equalsIgnoreCase(city)) {
                    return true;
                }
            }
        } catch (SQLException e) {
            result = false;
        }
        return result;
    }
项目:openjdk-jdk10    文件:CommonCachedRowSetTests.java   
@DataProvider(name = "rowsetUsingCoffees")
protected Object[][] rowsetUsingCoffees() throws Exception {
    RowSet rs = createCoffeesRowSet();
    return new Object[][]{
        {rs}
    };
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void commonRowSetTest0022(RowSet rs) throws Exception {
    Map<String, Class<?>> map = new HashMap<>();
    map.put("SUPERHERO", Class.forName("util.SuperHero"));
    rs.setTypeMap(map);
    assertTrue(rs.getTypeMap().equals(map));
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
protected void initCoffeesMetaData(CachedRowSet crs) throws SQLException {
    RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl();
    crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE);

    /*
     *  CREATE TABLE COFFEES (
     *   COF_ID INTEGER NOT NULL,
     *   COF_NAME VARCHAR(32) NOT NULL,
     *   SUP_ID INTEGER NOT NULL,
     *   PRICE NUMBERIC(10,2 NOT NULL,
     *   SALES INTEGER NOT NULL,
     *   TOTAL INTEGER NOT NULL,
     *   PRIMARY KEY (COF_ID),
     *   FOREIGN KEY (SUP_ID) REFERENCES SUPPLIERS (SUP_ID) )
     */
    rsmd.setColumnCount(COFFEES_COLUMN_NAMES.length);
    for(int i = 1; i <= COFFEES_COLUMN_NAMES.length; i++){
        rsmd.setColumnName(i, COFFEES_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.NUMERIC);
    rsmd.setPrecision(4, 10);
    rsmd.setScale(4, 2);
    rsmd.setColumnType(5, Types.INTEGER);
    rsmd.setColumnType(6, Types.INTEGER);
    crs.setMetaData(rsmd);
    crs.setTableName(COFFEES_TABLE);

}
项目:openjdk-jdk10    文件:JoinRowSetTests.java   
@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();
    }
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@DataProvider(name = "rowSetFetchDirection")
protected Object[][] rowSetFetchDirection() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, ResultSet.FETCH_FORWARD},
        {rs, ResultSet.FETCH_REVERSE},
        {rs, ResultSet.FETCH_UNKNOWN}
    };
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@DataProvider(name = "rowSetConcurrencyTypes")
protected Object[][] rowSetConcurrencyTypes() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, ResultSet.CONCUR_READ_ONLY},
        {rs, ResultSet.CONCUR_UPDATABLE}
    };
}
项目:jdk8u-jdk    文件:CommonCachedRowSetTests.java   
@DataProvider(name = "rowsetUsingCoffees")
protected Object[][] rowsetUsingCoffees() throws Exception {
    RowSet rs = createCoffeesRowSet();
    return new Object[][]{
        {rs}
    };
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void commonRowSetTest0006(RowSet rs) throws Exception {
    rs.setUrl(url);
    rs.setDataSourceName(dsName);
    assertTrue(rs.getDataSourceName().equals(dsName));
    assertNull(rs.getUrl());
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
protected void createCoffeesRows(RowSet rs) throws SQLException {

        // insert into COFFEES values(1, 'Colombian', 101, 7.99, 0, 0)
        rs.moveToInsertRow();
        rs.updateInt(1, 1);
        rs.updateString(2, "Colombian");
        rs.updateInt(3, 101);
        rs.updateBigDecimal(4, BigDecimal.valueOf(7.99));
        rs.updateInt(5, 0);
        rs.updateInt(6, 0);
        rs.insertRow();
        // insert into COFFEES values(2, 'French_Roast', 49, 8.99, 0, 0)
        rs.moveToInsertRow();
        rs.updateInt(1, 2);
        rs.updateString(2, "French_Roast");
        rs.updateInt(3, 49);
        rs.updateBigDecimal(4, BigDecimal.valueOf(8.99));
        rs.updateInt(5, 0);
        rs.updateInt(6, 0);
        rs.insertRow();
        // insert into COFFEES values(3, 'Espresso', 150, 9.99, 0, 0)
        rs.moveToInsertRow();
        rs.updateInt(1, 3);
        rs.updateString(2, "Espresso");
        rs.updateInt(3, 150);
        rs.updateBigDecimal(4, BigDecimal.valueOf(9.99));
        rs.updateInt(5, 0);
        rs.updateInt(6, 0);
        rs.insertRow();
        // insert into COFFEES values(4, 'Colombian_Decaf', 101, 8.99, 0, 0)
        rs.moveToInsertRow();
        rs.updateInt(1, 4);
        rs.updateString(2, "Colombian_Decaf");
        rs.updateInt(3, 101);
        rs.updateBigDecimal(4, BigDecimal.valueOf(8.99));
        rs.updateInt(5, 0);
        rs.updateInt(6, 0);
        rs.insertRow();
        // insert into COFFEES values(5, 'French_Roast_Decaf', 049, 9.99, 0, 0)
        rs.moveToInsertRow();
        rs.updateInt(1, 5);
        rs.updateString(2, "French_Roast_Decaf");
        rs.updateInt(3, 49);
        rs.updateBigDecimal(4, BigDecimal.valueOf(9.99));
        rs.updateInt(5, 0);
        rs.updateInt(6, 0);
        rs.insertRow();

    }
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0141(RowSet rs) throws Exception {
    rs.setNString(1, query);
}
项目:jdk8u-jdk    文件:StubWebRowSetImpl.java   
@Override
public RowSet createShared() throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void commonRowSetTest0024(RowSet rs) throws Exception {
    rs.setPassword(password);
    assertTrue(rs.getPassword().equals(password));
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0108(RowSet rs) throws Exception {
    InputStream is = null;
    rs.setBlob("one", is);
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetTrueFalse")
public void commonRowSetTest0018(RowSet rs, boolean val) throws Exception {
    rs.setReadOnly(val);
    assertTrue(rs.isReadOnly() == val);
}
项目:jdk8u-jdk    文件:StubJoinRowSetImpl.java   
@Override
public void addRowSet(RowSet rowset, String columnName) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:jdk8u-jdk    文件:StubJoinRowSetImpl.java   
@Override
public void addRowSet(RowSet[] rowset, int[] columnIdx) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:jdk8u-jdk    文件:StubJoinRowSetImpl.java   
@Override
public void addRowSet(RowSet[] rowset, String[] columnName) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:jdk8u-jdk    文件:StubJoinRowSetImpl.java   
@Override
public RowSet createShared() throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0101(RowSet rs) throws Exception {
    InputStream is = null;
    rs.setAsciiStream("one", is);
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0140(RowSet rs) throws Exception {
    rs.setNClob(1, new StubNClob());
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0130(RowSet rs) throws Exception {
    rs.setLong("one", 21l);
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0138(RowSet rs) throws Exception {
    Reader rdr = null;
    rs.setNClob(1, rdr);
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0145(RowSet rs) throws Exception {
    rs.setObject("one", query, Types.VARCHAR, 0);
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetFetchDirection")
public void commonRowSetTest0011(RowSet rs, int direction) throws Exception {
    rs.setFetchDirection(direction);
    assertTrue(rs.getFetchDirection() == direction);
}
项目:openjdk-jdk10    文件:CommonRowSetTests.java   
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0106(RowSet rs) throws Exception {
    rs.setBigDecimal("one", BigDecimal.ONE);
}