Examples of JdbcRowSet


Examples of javax.sql.rowset.JdbcRowSet

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

        // Creates jdbc rowset.
        JdbcRowSet jdbcRs;
        jdbcRs = newJdbcRowSet();
        jdbcRs.setCommand("SELECT * FROM USER_INFO");
        jdbcRs.setUrl(DERBY_URL);
        jdbcRs.execute();

        jdbcRs.setMatchColumn("ID");
        jrs.addRowSet(jdbcRs);

        if (System.getProperty("Testing Harmony") == "true") {
            whereClause = jrs.getWhereClause();
            assertNotNull(whereClause);
View Full Code Here

Examples of javax.sql.rowset.JdbcRowSet

        }

    }

    public void testSetMatchColumn_Index() throws Exception {
        JdbcRowSet noInitalJrs = noInitalJdbcRowSet();
        JdbcRowSet jrs = newJdbcRowSet();
        try {
            noInitalJrs.setMatchColumn(-2);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Match columns should be greater than 0
        }

        int[] indexes = null;

        try {
            noInitalJrs.setMatchColumn(indexes);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }

        // TODO 0 is valid index 0f column?
        noInitalJrs.setMatchColumn(0);
        indexes = noInitalJrs.getMatchColumnIndexes();

        assertNotNull(indexes);
        assertEquals(10, indexes.length);
        for (int i = 0; i < indexes.length; i++) {
            if (i == 0) {
                assertEquals(0, indexes[i]);
            } else {
                assertEquals(-1, indexes[i]);
            }
        }

        noInitalJrs.setMatchColumn(1);
        indexes = noInitalJrs.getMatchColumnIndexes();
        assertNotNull(indexes);
        assertEquals(10, indexes.length);
        for (int i = 0; i < indexes.length; i++) {
            if (i == 0) {
                assertEquals(1, indexes[i]);
            } else {
                assertEquals(-1, indexes[i]);
            }
        }

        noInitalJrs.setMatchColumn(new int[] { 3, 4, 5 });
        indexes = noInitalJrs.getMatchColumnIndexes();

        try {
            noInitalJrs.setMatchColumn(new int[] { 3, -3 });
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Match columns should be greater than 0
        }

        assertNotNull(indexes);
        assertEquals(13, indexes.length);
        assertEquals(3, indexes[0]);
        assertEquals(4, indexes[1]);
        assertEquals(5, indexes[2]);
        assertEquals(1, indexes[3]);

        for (int i = 4; i < indexes.length; i++) {
            assertEquals(-1, indexes[i]);
        }

        noInitalJrs.setMatchColumn(6);
        indexes = noInitalJrs.getMatchColumnIndexes();
        assertNotNull(indexes);
        assertEquals(13, indexes.length);
        assertEquals(6, indexes[0]);
        assertEquals(4, indexes[1]);
        assertEquals(5, indexes[2]);
        assertEquals(1, indexes[3]);

        noInitalJrs.setMatchColumn(new int[] { 7, 8 });
        indexes = noInitalJrs.getMatchColumnIndexes();
        assertNotNull(indexes);
        assertEquals(15, indexes.length);
        assertEquals(7, indexes[0]);
        assertEquals(8, indexes[1]);
        assertEquals(6, indexes[2]);
        assertEquals(4, indexes[3]);
        assertEquals(5, indexes[4]);
        assertEquals(1, indexes[5]);

        for (int i = 6; i < indexes.length; i++) {
            assertEquals(-1, indexes[i]);
        }

        noInitalJrs.setMatchColumn(9);
        indexes = noInitalJrs.getMatchColumnIndexes();
        assertNotNull(indexes);
        assertEquals(15, indexes.length);
        assertEquals(9, indexes[0]);
        assertEquals(8, indexes[1]);
        assertEquals(6, indexes[2]);
        assertEquals(4, indexes[3]);
        assertEquals(5, indexes[4]);
        assertEquals(1, indexes[5]);

        for (int i = 6; i < indexes.length; i++) {
            assertEquals(-1, indexes[i]);
        }

        try {
            jrs.setMatchColumn(-2);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Match columns should be greater than 0
        }

        indexes = null;

        try {
            jrs.setMatchColumn(indexes);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }

        jrs.setMatchColumn(0);
        indexes = jrs.getMatchColumnIndexes();

        assertNotNull(indexes);
        assertEquals(10, indexes.length);
        for (int i = 0; i < indexes.length; i++) {
            if (i == 0) {
                assertEquals(0, indexes[i]);
            } else {
                assertEquals(-1, indexes[i]);
            }
        }

        jrs.setMatchColumn(1);
        indexes = jrs.getMatchColumnIndexes();
        assertNotNull(indexes);
        assertEquals(10, indexes.length);
        for (int i = 0; i < indexes.length; i++) {
            if (i == 0) {
                assertEquals(1, indexes[i]);
            } else {
                assertEquals(-1, indexes[i]);
            }
        }

        jrs.setMatchColumn(new int[] { 3, 4, 5 });
        indexes = jrs.getMatchColumnIndexes();

        assertNotNull(indexes);
        assertEquals(13, indexes.length);
        assertEquals(3, indexes[0]);
        assertEquals(4, indexes[1]);
        assertEquals(5, indexes[2]);
        assertEquals(1, indexes[3]);

        for (int i = 4; i < indexes.length; i++) {
            assertEquals(-1, indexes[i]);
        }

        jrs.setMatchColumn(6);
        indexes = jrs.getMatchColumnIndexes();
        assertNotNull(indexes);
        assertEquals(13, indexes.length);
        assertEquals(6, indexes[0]);
        assertEquals(4, indexes[1]);
        assertEquals(5, indexes[2]);
        assertEquals(1, indexes[3]);

        for (int i = 4; i < indexes.length; i++) {
            assertEquals(-1, indexes[i]);
        }

        jrs.setMatchColumn(new int[] { 7, 8 });
        indexes = jrs.getMatchColumnIndexes();
        assertNotNull(indexes);
        assertEquals(15, indexes.length);
        assertEquals(7, indexes[0]);
        assertEquals(8, indexes[1]);
        assertEquals(6, indexes[2]);
        assertEquals(4, indexes[3]);
        assertEquals(5, indexes[4]);
        assertEquals(1, indexes[5]);

        for (int i = 6; i < indexes.length; i++) {
            assertEquals(-1, indexes[i]);
        }

        jrs.setMatchColumn(9);
        indexes = jrs.getMatchColumnIndexes();
        assertNotNull(indexes);
        assertEquals(15, indexes.length);
        assertEquals(9, indexes[0]);
        assertEquals(8, indexes[1]);
        assertEquals(6, indexes[2]);
        assertEquals(4, indexes[3]);
        assertEquals(5, indexes[4]);
        assertEquals(1, indexes[5]);

        for (int i = 6; i < indexes.length; i++) {
            assertEquals(-1, indexes[i]);
        }

        // exceed column count
        jrs.setMatchColumn(100);
        assertEquals(100, jrs.getMatchColumnIndexes()[0]);

        noInitalJrs = noInitalJdbcRowSet();

        noInitalJrs.setMatchColumn(new int[] { 1, 2, 3 });
        indexes = noInitalJrs.getMatchColumnIndexes();
View Full Code Here

Examples of javax.sql.rowset.JdbcRowSet

        noInitalJrs = noInitalJdbcRowSet();

    }

    public void testGetMatchColumn() throws Exception {
        JdbcRowSet noInitalJrs = noInitalJdbcRowSet();
        JdbcRowSet jrs = newJdbcRowSet();
        try {
            noInitalJrs.getMatchColumnIndexes();
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Set Match columns before getting them
View Full Code Here

Examples of javax.sql.rowset.JdbcRowSet

                .getMatchColumnNames());

    }

    public void testUnsetMatchColumn_Index_Unpopulate() throws Exception {
        JdbcRowSet noInitalJrs = noInitalJdbcRowSet();
        JdbcRowSet jrs = newJdbcRowSet();
        int[] indexes = null;
        try {
            noInitalJrs.unsetMatchColumn(indexes);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
View Full Code Here

Examples of javax.sql.rowset.JdbcRowSet

        assertEquals(2, indexes[5]);
        assertEquals(3, indexes[6]);
    }

    public void testUnsetMatchColumn_Index() throws Exception {
        JdbcRowSet noInitalJrs = noInitalJdbcRowSet();
        JdbcRowSet jrs = newJdbcRowSet();
        int[] indexes = null;
        try {
            jrs.unsetMatchColumn(indexes);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }

        indexes = new int[0];

        jrs.unsetMatchColumn(indexes);

        indexes = new int[] { 1, 2, 3 };
        try {
            jrs.unsetMatchColumn(indexes);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }

        try {
            jrs.unsetMatchColumn(-2);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }

        try {
            jrs.unsetMatchColumn(0);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }

        jrs.setMatchColumn(1);
        try {
            jrs.unsetMatchColumn(2);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }

        jrs.unsetMatchColumn(1);

        try {
            indexes = jrs.getMatchColumnIndexes();
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Set Match columns before getting them
        }

        jrs.setMatchColumn(new int[] { 1, 2, 3 });

        try {
            jrs.unsetMatchColumn(2);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }
        try {
            jrs.unsetMatchColumn(3);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }

        jrs.unsetMatchColumn(1);

        try {
            jrs.getMatchColumnIndexes();
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Set Match columns before getting them
        }

        jrs.setMatchColumn(4);
        indexes = jrs.getMatchColumnIndexes();
        assertNotNull(indexes);
        assertEquals(13, indexes.length);
        assertEquals(4, indexes[0]);
        assertEquals(2, indexes[1]);
        assertEquals(3, indexes[2]);
        for (int i = 3; i < indexes.length; i++) {
            assertEquals(-1, indexes[i]);
        }

        try {
            jrs.unsetMatchColumn(2);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }
        try {
            jrs.unsetMatchColumn(3);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }

        jrs.setMatchColumn(new int[] { 5, 6 });
        try {
            jrs.unsetMatchColumn(2);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }
        try {
            jrs.unsetMatchColumn(3);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }
        try {
            jrs.unsetMatchColumn(4);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }
        try {
            jrs.unsetMatchColumn(6);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }

        jrs.unsetMatchColumn(5);

        try {
            jrs.getMatchColumnIndexes();
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Set Match columns before getting them
        }

        jrs.setMatchColumn(7);
        indexes = jrs.getMatchColumnIndexes();
        assertNotNull(indexes);
        assertEquals(15, indexes.length);
        assertEquals(7, indexes[0]);
        assertEquals(6, indexes[1]);
        assertEquals(4, indexes[2]);
        assertEquals(2, indexes[3]);
        assertEquals(3, indexes[4]);

        for (int i = 6; i < indexes.length; i++) {
            assertEquals(-1, indexes[i]);
        }

        jrs.unsetMatchColumn(new int[] { 7, 6 });
        try {
            jrs.getMatchColumnIndexes();
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Set Match columns before getting them
        }

        jrs.setMatchColumn(new int[] { 7, 6 });
        indexes = jrs.getMatchColumnIndexes();

        assertNotNull(indexes);
        assertEquals(17, indexes.length);
        assertEquals(7, indexes[0]);
        assertEquals(6, indexes[1]);
        assertEquals(-1, indexes[2]);
        assertEquals(-1, indexes[3]);
        assertEquals(4, indexes[4]);
        assertEquals(2, indexes[5]);
        assertEquals(3, indexes[6]);

        jrs.unsetMatchColumn(new int[] { 7, 6, -1, -1, 4, 2, 3 });
        try {
            indexes = jrs.getMatchColumnIndexes();
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Set Match columns before getting them
        }
    }
View Full Code Here

Examples of javax.sql.rowset.JdbcRowSet

            // expected, Set Match columns before getting them
        }
    }

    public void testUnsetMatchColumn_Name_Unpopulate() throws Exception {
        JdbcRowSet noInitalJrs = noInitalJdbcRowSet();
        JdbcRowSet jrs = newJdbcRowSet();
        String[] names = null;
        try {
            noInitalJrs.unsetMatchColumn(names);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
View Full Code Here

Examples of javax.sql.rowset.JdbcRowSet

        assertEquals("2", names[5]);
        assertEquals("3", names[6]);
    }

    public void testUnsetMatchColumn_Name() throws Exception {
        JdbcRowSet noInitalJrs = noInitalJdbcRowSet();
        JdbcRowSet jrs = newJdbcRowSet();
        String[] names = null;
        try {
            jrs.unsetMatchColumn(names);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }

        names = new String[0];

        jrs.unsetMatchColumn(names);

        names = new String[] { "1", "2", "3" };
        try {
            jrs.unsetMatchColumn(names);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }

        /*
         * TODO behavior of unsetMatchColumn(String) is not the same with
         * unsetMatchColumn(int) in RI, we think throw SQLException is more
         * reasonable
         */
        if ("true".equals(System.getProperty("Testing Harmony"))) {
            try {
                jrs.unsetMatchColumn("");
                fail("Should throw SQLException");
            } catch (SQLException e) {
                // expected, Columns being unset are not the same as set
            }
            try {
                jrs.unsetMatchColumn("0");
                fail("Should throw SQLException");
            } catch (SQLException e) {
                // expected, Columns being unset are not the same as set
            }
        } else {
            try {
                jrs.unsetMatchColumn("");
                fail("Should throw NullPointerException");
            } catch (NullPointerException e) {
                // expected
            }

            try {
                jrs.unsetMatchColumn("0");
                fail("Should throw NullPointerException");
            } catch (NullPointerException e) {
                // expected
            }

        }

        jrs.setMatchColumn("1");
        try {
            jrs.unsetMatchColumn("2");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }

        jrs.unsetMatchColumn("1");

        try {
            jrs.getMatchColumnNames();
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Set Match columns before getting them
        }

        jrs.setMatchColumn(new String[] { "1", "2", "3" });

        try {
            jrs.unsetMatchColumn("2");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }
        try {
            jrs.unsetMatchColumn("3");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }

        jrs.unsetMatchColumn("1");

        try {
            jrs.getMatchColumnNames();
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Set Match columns before getting them
        }

        jrs.setMatchColumn("4");
        names = jrs.getMatchColumnNames();
        assertNotNull(names);
        assertEquals(13, names.length);
        assertEquals("4", names[0]);
        assertEquals("2", names[1]);
        assertEquals("3", names[2]);
        for (int i = 3; i < names.length; i++) {
            assertNull(names[i]);
        }

        try {
            jrs.unsetMatchColumn("2");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }
        try {
            jrs.unsetMatchColumn("3");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }

        jrs.setMatchColumn(new String[] { "5", "6" });
        try {
            jrs.unsetMatchColumn("2");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }
        try {
            jrs.unsetMatchColumn("3");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }
        try {
            jrs.unsetMatchColumn("4");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }
        try {
            jrs.unsetMatchColumn("6");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }

        jrs.unsetMatchColumn("5");

        try {
            jrs.getMatchColumnNames();
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Set Match columns before getting them
        }

        jrs.setMatchColumn("7");
        names = jrs.getMatchColumnNames();
        assertNotNull(names);
        assertEquals(15, names.length);
        assertEquals("7", names[0]);
        assertEquals("6", names[1]);
        assertEquals("4", names[2]);
        assertEquals("2", names[3]);
        assertEquals("3", names[4]);

        for (int i = 6; i < names.length; i++) {
            assertNull(names[i]);
        }

        jrs.unsetMatchColumn(new String[] { "7", "6" });
        try {
            jrs.getMatchColumnNames();
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Set Match columns before getting them
        }

        jrs.setMatchColumn(new String[] { "7", "6" });
        names = jrs.getMatchColumnNames();

        assertNotNull(names);
        assertEquals(17, names.length);
        assertEquals("7", names[0]);
        assertEquals("6", names[1]);
        assertNull(names[2]);
        assertNull(names[3]);
        assertEquals("4", names[4]);
        assertEquals("2", names[5]);
        assertEquals("3", names[6]);

        jrs = noInitalJdbcRowSet();

        // test whether column name is case sensitive
        jrs.setMatchColumn("TesT");
        assertEquals("TesT", jrs.getMatchColumnNames()[0]);
        try {
            jrs.unsetMatchColumn("test");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Columns being unset are not the same as set
        }
    }
View Full Code Here

Examples of javax.sql.rowset.JdbcRowSet

                    .newInstance();
        }
    }

    protected JdbcRowSet newJdbcRowSet() throws Exception {
        JdbcRowSet noInitalJrs = noInitalJdbcRowSet();
        noInitalJrs.setUrl(DERBY_URL);
        noInitalJrs.setCommand("SELECT * FROM USER_INFO");
        noInitalJrs.execute();
        return noInitalJrs;
    }
View Full Code Here

Examples of javax.sql.rowset.JdbcRowSet

        return (JdbcRowSet) Class.forName("com.sun.rowset.JdbcRowSetImpl")
                .newInstance();
    }

    public void testGetXXX() throws Exception {
        JdbcRowSet jrs = newJdbcRowSet();

        try {
            jrs.getHoldability();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            jrs.getNCharacterStream(100);
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            jrs.getNCharacterStream("not");
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            jrs.getNClob(100);
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            jrs.getNClob("not");
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            jrs.getNString(100);
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            jrs.getNString("not");
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            jrs.getRowId(100);
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            jrs.getRowId("not");
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            jrs.getSQLXML(100);
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            jrs.getSQLXML("not");
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }
    }
View Full Code Here

Examples of javax.sql.rowset.JdbcRowSet

            // expected
        }
    }

    public void testIsClosed() throws Exception {
        JdbcRowSet jrs = newJdbcRowSet();
        try {
            jrs.isClosed();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.