javax.sql.RowSet Java Examples

The following examples show how to use javax.sql.RowSet. 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 openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example #2
Source File: PrimaryKeyFilter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public boolean evaluate(RowSet rs) {

        boolean result = false;
        try {
            int columnValue = -1;

            if (this.colNumber > 0) {
                columnValue = rs.getInt(this.colNumber);
            } else if (this.colName != null) {
                columnValue = rs.getInt(this.colName);
            }
            if ((columnValue >= this.lo) && (columnValue <= this.hi)) {
                result = true;
            }

        } catch (Exception e) {
            System.out.println("Error:" + e.getMessage());
            result = false;
        }
        return result;
    }
 
Example #3
Source File: CommonCachedRowSetTests.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example #4
Source File: CommonCachedRowSetTests.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example #5
Source File: CommonRowSetTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);

}
 
Example #6
Source File: CommonRowSetTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "rowSetTrueFalse")
protected Object[][] rowSetTrueFalse() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, true},
        {rs, false}
    };
}
 
Example #7
Source File: CityFilter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
 
Example #8
Source File: CommonCachedRowSetTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0006(RowSet rs) throws Exception {
    TestRowSetListener rsl = new TestRowSetListener();
    rs.addRowSetListener(rsl);
    rs.moveToInsertRow();
    rs.updateInt(1, 10024);
    rs.updateString(2, "Sacramento");
    rs.updateInt(3, 1987);
    rs.updateInt(4, 2341);
    rs.updateInt(5, 4328);
    rs.insertRow();
    assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED));
    rs.close();
}
 
Example #9
Source File: CommonRowSetTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "rowSetConcurrencyTypes")
protected Object[][] rowSetConcurrencyTypes() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, ResultSet.CONCUR_READ_ONLY},
        {rs, ResultSet.CONCUR_UPDATABLE}
    };
}
 
Example #10
Source File: CityFilter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
 
Example #11
Source File: JdbcRowSetAccessor.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    //super.readExternal(in);
    connectionManager = (String)in.readObject();
    connectionName = (String)in.readObject();
    connectionUrl = (String)in.readObject();
    query = (String)in.readObject();
    rowSet = (RowSet)in.readObject();
    parameters = (List<Object>)in.readObject();
}
 
Example #12
Source File: CommonRowSetTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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));
}
 
Example #13
Source File: CommonCachedRowSetTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "rowsetUsingCoffees")
protected Object[][] rowsetUsingCoffees() throws Exception {
    RowSet rs = createCoffeesRowSet();
    return new Object[][]{
        {rs}
    };
}
 
Example #14
Source File: CommonCachedRowSetTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #15
Source File: CommonRowSetTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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));
}
 
Example #16
Source File: CommonRowSetTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "rowSetTrueFalse")
protected Object[][] rowSetTrueFalse() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, true},
        {rs, false}
    };
}
 
Example #17
Source File: CommonCachedRowSetTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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();

    }
 
Example #18
Source File: CommonRowSetTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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}
    };
}
 
Example #19
Source File: CommonCachedRowSetTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #20
Source File: CommonRowSetTests.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "rowSetType")
public void commonRowSetTest0008(RowSet rs) throws Exception {
    assertTrue(rs.getEscapeProcessing());
}
 
Example #21
Source File: CommonRowSetTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0137(RowSet rs) throws Exception {
    rs.setNClob("one", new StubNClob());
}
 
Example #22
Source File: CommonRowSetTests.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "rowSetScrollTypes")
public void commonRowSetTest0020(RowSet rs, int val) throws Exception {
    rs.setType(val);
    assertTrue(rs.getType() == val);
}
 
Example #23
Source File: CommonRowSetTests.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0150(RowSet rs) throws Exception {
    rs.setNString(1, query);
}
 
Example #24
Source File: CommonRowSetTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0115(RowSet rs) throws Exception {
    Reader rdr = null;
    rs.setCharacterStream("one", rdr);
}
 
Example #25
Source File: CommonRowSetTests.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0146(RowSet rs) throws Exception {
    rs.setObject("one", query);
}
 
Example #26
Source File: CommonRowSetTests.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0105(RowSet rs) throws Exception {
    InputStream is = null;
    rs.setBinaryStream("one", is, query.length());
}
 
Example #27
Source File: CommonRowSetTests.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "rowSetScrollTypes")
public void commonRowSetTest0020(RowSet rs, int val) throws Exception {
    rs.setType(val);
    assertTrue(rs.getType() == val);
}
 
Example #28
Source File: StubJoinRowSetImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public RowSet createShared() throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example #29
Source File: CommonRowSetTests.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0141(RowSet rs) throws Exception {
    rs.setNString(1, query);
}
 
Example #30
Source File: CommonRowSetTests.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0133(RowSet rs) throws Exception {
    Reader rdr = null;
    rs.setNCharacterStream(1, rdr);
}