Package javax.sql.rowset

Examples of javax.sql.rowset.CachedRowSet


    public void tearDown() throws Exception {
        super.tearDown();
    }

    public void testNotSupportMethods() throws Exception {
        CachedRowSet copy = crset.createCopy();

        copy.absolute(3);
        crset.absolute(3);

        copy.updateString(2, "updated");
        assertEquals("updated", copy.getString(2));
        assertEquals("test3", crset.getString(2));

        copy.updateRow();
        copy.acceptChanges();

        assertEquals(copy.getString(2), "updated");
        assertEquals(crset.getString(2), "test3");

        crset.updateString(2, "again");

        assertEquals(copy.getString(2), "updated");
        assertEquals(crset.getString(2), "again");

        crset.updateRow();

        SyncProviderException ex = null;
View Full Code Here


        webRs.setUrl(DERBY_URL);
        webRs.setCommand("SELECT * FROM USER_INFO WHERE ID = ?");
        webRs.setInt(1, 3);
        webRs.execute();

        CachedRowSet copyWebRs = webRs.createCopy();
        assertTrue(copyWebRs instanceof WebRowSet);
        assertEquals("SELECT * FROM USER_INFO WHERE ID = ?", copyWebRs
                .getCommand());
        assertEquals(DERBY_URL, copyWebRs.getUrl());
    }
View Full Code Here

        assertTrue(webRs.next());
        assertEquals(3, webRs.getInt(1));
        assertFalse(webRs.next());

        // deep copy
        CachedRowSet copyWebRs = webRs.createCopy();
        copyWebRs.beforeFirst();
        assertTrue(copyWebRs.next());
        assertEquals(3, copyWebRs.getInt(1));
        assertFalse(copyWebRs.next());
        copyWebRs.execute();
        assertTrue(copyWebRs.next());
        assertEquals(3, copyWebRs.getInt(1));
        assertFalse(copyWebRs.next());

        webRs.setInt(1, 4);
        webRs.setString(2, "test4");
        webRs.execute();
        webRs.beforeFirst();
        assertTrue(webRs.next());
        assertEquals(4, webRs.getInt(1));
        assertFalse(webRs.next());

        copyWebRs.beforeFirst();
        assertTrue(copyWebRs.next());
        assertEquals(3, copyWebRs.getInt(1));
        assertFalse(copyWebRs.next());

        copyWebRs.execute();
        copyWebRs.beforeFirst();
        assertTrue(copyWebRs.next());
        assertEquals(3, copyWebRs.getInt(1));
        assertFalse(copyWebRs.next());

        copyWebRs.setInt(1, 1);
        copyWebRs.setString(2, "hermit");
        copyWebRs.execute();
        assertTrue(copyWebRs.next());
        assertEquals(1, copyWebRs.getInt(1));
        assertFalse(copyWebRs.next());

        webRs.beforeFirst();
        assertTrue(webRs.next());
        assertEquals(4, webRs.getInt(1));
        assertFalse(webRs.next());
View Full Code Here

     * @tests java.sql.rowset.joinRowSet#getRowSets()
     */
    public void testGetRowSets_SingleCachedRowSet() throws Exception {
        crset.setMatchColumn(1);
        jrs.addRowSet(crset);
        CachedRowSet returnRowset = (CachedRowSet) jrs.getRowSets().iterator()
                .next();
        // Since the returnRowset is the same with the original one,
        // so we no need to test FilteredRowSet, JoinRowSet, WebRowSet
        // because they are all subInterface of CachedRowSet.
        assertSame(returnRowset, crset);
View Full Code Here

        jdbcRs.execute();

        jdbcRs.setMatchColumn(1);
        jrs.addRowSet(jdbcRs);

        CachedRowSet returnRowset = (CachedRowSet) jrs.getRowSets().iterator()
                .next();
        assertNotSame(returnRowset, jrs);

        jrs.absolute(4);
        jrs.updateString(2, "Updated 4");
        jrs.updateRow();

        jrs.absolute(4);
        assertEquals("Updated 4", jrs.getString(2));

        // TODO It is Strange. According to spec, the returned rowset should
        // maintain
        // the update occured in the joinrowset.
        returnRowset.absolute(4);
        assertEquals("test4", returnRowset.getString(2));

        jdbcRs.absolute(3);
        jdbcRs.updateString(2, "Updated 3");
        jdbcRs.updateRow();

        returnRowset.absolute(3);
        assertEquals("test3", returnRowset.getString(2));

        jdbcRs.close();
    }
View Full Code Here

     * @tests java.sql.rowset.joinRowSet#addRowSet()
     */
    public void testAddRowSet_NoInitialCachedRowSet() throws Exception {
        Collection collection;

        CachedRowSet crs = newNoInitialInstance();
       
        if ("true".equals(System.getProperty("Testing Harmony"))) {
            try {
                jrs.addRowSet(crs, 1);
                fail("Should throw SQLException in harmony.");
View Full Code Here

    public void testGetRowSets_MultipleCachedRowSet() throws Exception {
        Collection collection;

        rs = st.executeQuery("select * from USER_INFO");
        CachedRowSet crset2 = newNoInitialInstance();
        crset2.populate(rs);

        jrs.addRowSet(crset, 1);
        jrs.addRowSet(crset2, 1);

        collection = jrs.getRowSets();
View Full Code Here

            } catch (NullPointerException e) {
                // Expected.
            }
        }

        CachedRowSet rowSetInJrs = (CachedRowSet) jrs.getRowSets().iterator()
                .next();
        rowSetInJrs.setTableName("Table1");

        whereClause = jrs.getWhereClause();
        assertNotNull(whereClause);
    }
View Full Code Here

     */
    public void testGetWhereClause_MultipleCachedRowSet() throws Exception {
        String whereClause;

        // Creates another cached rowset.
        CachedRowSet crset2;
        crset2 = newNoInitialInstance();
        crset2.setCommand("SELECT * FROM BOOKS");
        crset2.setUrl(DERBY_URL);
        crset2.execute();

        // Tests when there are on jdbcRowSet and one CachedRowSet.
        jrs.addRowSet(crset2, 1);
        jrs.addRowSet(crset, 1);

        if (System.getProperty("Testing Harmony") == "true") {
            whereClause = jrs.getWhereClause();
            assertNotNull(whereClause);
        } else {
            try {
                whereClause = jrs.getWhereClause();
                fail("Should throw NullPointerException.");
            } catch (NullPointerException e) {
                // Expected.
            }
        }
        crset.setTableName("Table1");
        crset2.setTableName("Table2");
        if (System.getProperty("Testing Harmony") == "true") {
            whereClause = jrs.getWhereClause();
            assertNotNull(whereClause);
        } else {
            try {
                whereClause = jrs.getWhereClause();
                fail("Should throw SQLException.");
            } catch (SQLException e) {
                // Expected.
            }
        }

        crset.setMatchColumn("ID");
        crset2.setMatchColumn("AUTHORID");
        whereClause = jrs.getWhereClause();
        assertNotNull(whereClause);

        jrs = newJoinRowSet();
        jrs.addRowSet(crset2, "AUTHORID");
        jrs.addRowSet(crset, "ID");
        whereClause = jrs.getWhereClause();
        assertNotNull(whereClause);

        crset2.close();
    }
View Full Code Here

    public void testGetWhereClause_MoreRowSets() throws Exception {
        crset.setTableName("Table1");
        jrs.addRowSet(crset, "ID");

        // Creates another cached rowset.
        CachedRowSet crset2;
        crset2 = newNoInitialInstance();
        crset2.setCommand("SELECT * FROM BOOKS");
        crset2.setUrl(DERBY_URL);
        crset2.execute();
        crset2.setTableName("Table2");
        jrs.addRowSet(crset2, "AUTHORID");

        crset2 = newNoInitialInstance();
        crset2.setCommand("SELECT * FROM BOOKS");
        crset2.setUrl(DERBY_URL);
        crset2.execute();
        crset2.setTableName("Table3");
        jrs.addRowSet(crset2, "AUTHORID");

        String whereClause = jrs.getWhereClause();
        assertNotNull(whereClause);
    }
View Full Code Here

TOP

Related Classes of javax.sql.rowset.CachedRowSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.