Java Code Examples for javax.sql.RowSet

The following examples show how to use javax.sql.RowSet. These examples are extracted from open source projects. 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
@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 Project: jdk8u-jdk   Source File: PrimaryKeyFilter.java    License: 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
@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
@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 Project: hottub   Source File: CommonRowSetTests.java    License: 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
@DataProvider(name = "rowSetTrueFalse")
protected Object[][] rowSetTrueFalse() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, true},
        {rs, false}
    };
}
 
Example 7
Source Project: jdk8u60   Source File: CityFilter.java    License: 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
@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
@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
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 Project: XPagesExtensionLibrary   Source File: JdbcRowSetAccessor.java    License: 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
@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
@DataProvider(name = "rowsetUsingCoffees")
protected Object[][] rowsetUsingCoffees() throws Exception {
    RowSet rs = createCoffeesRowSet();
    return new Object[][]{
        {rs}
    };
}
 
Example 14
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
@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 Project: hottub   Source File: CommonRowSetTests.java    License: 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
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 Project: jdk8u-jdk   Source File: CommonRowSetTests.java    License: 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
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
@Test(dataProvider = "rowSetType")
public void commonRowSetTest0008(RowSet rs) throws Exception {
    assertTrue(rs.getEscapeProcessing());
}
 
Example 21
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0137(RowSet rs) throws Exception {
    rs.setNClob("one", new StubNClob());
}
 
Example 22
Source Project: hottub   Source File: CommonRowSetTests.java    License: 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
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0150(RowSet rs) throws Exception {
    rs.setNString(1, query);
}
 
Example 24
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0115(RowSet rs) throws Exception {
    Reader rdr = null;
    rs.setCharacterStream("one", rdr);
}
 
Example 25
Source Project: hottub   Source File: CommonRowSetTests.java    License: 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
@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 Project: jdk8u_jdk   Source File: CommonRowSetTests.java    License: 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
@Override
public RowSet createShared() throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 29
Source Project: jdk8u-jdk   Source File: CommonRowSetTests.java    License: 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
@Test(dataProvider = "rowSetType",
        expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0133(RowSet rs) throws Exception {
    Reader rdr = null;
    rs.setNCharacterStream(1, rdr);
}