Package java.sql

Examples of java.sql.PreparedStatement.execute()


                rs.getString(1));

        PreparedStatement prep;
        prep = conn.prepareStatement("SELECT * FROM TEST LIMIT ?");
        prep.setInt(1, 10);
        prep.execute();

        prep = conn.prepareStatement("DELETE FROM TEST LIMIT ?");
        prep.setInt(1, 10);
        prep.execute();
        rs = stat.executeQuery("SELECT COUNT(*) FROM TEST");
View Full Code Here


        prep.setInt(1, 10);
        prep.execute();

        prep = conn.prepareStatement("DELETE FROM TEST LIMIT ?");
        prep.setInt(1, 10);
        prep.execute();
        rs = stat.executeQuery("SELECT COUNT(*) FROM TEST");
        assertTrue(rs.next());
        assertEquals(71, rs.getInt(1));

        conn.close();
View Full Code Here

        stat.execute("CREATE TABLE TEST(ID INT)");
        stat.execute("INSERT INTO TEST VALUES(1)");
        prep = conn.prepareStatement("SELECT * FROM TEST");
        // just to check if it doesn't throw an exception - it may be null
        prep.getMetaData();
        assertTrue(prep.execute());
        rs = prep.getResultSet();
        assertFalse(prep.getMoreResults());
        // supposed to be closed now
        assertThrows(ErrorCode.OBJECT_CLOSED, rs).next();
        assertTrue(prep.getUpdateCount() == -1);
View Full Code Here

        for (int i = 0; i < 5; i++) {
            prep.setInt(1, i);
            if (i % 2 == 0) {
                prep.setCharacterStream(2, new StringReader(getString(i)), -1);
            }
            prep.execute();
        }
        ResultSet rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID");
        int check = 0;
        for (int i = 0; i < 5; i++) {
            assertTrue(rs.next());
View Full Code Here

        stat.execute("CREATE TABLE TEST(ID INT, H BINARY)");
        prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, HASH('SHA256', STRINGTOUTF8(?), 5))");
        prep.setInt(1, 1);
        prep.setString(2, "One");
        prep.execute();
        prep.setInt(1, 2);
        prep.setString(2, "Two");
        prep.execute();
        rs = stat.executeQuery("SELECT COUNT(DISTINCT H) FROM TEST");
        rs.next();
View Full Code Here

        prep.setInt(1, 1);
        prep.setString(2, "One");
        prep.execute();
        prep.setInt(1, 2);
        prep.setString(2, "Two");
        prep.execute();
        rs = stat.executeQuery("SELECT COUNT(DISTINCT H) FROM TEST");
        rs.next();
        assertEquals(2, rs.getInt(1));

        stat.execute("DROP TABLE TEST");
View Full Code Here

    private void testUnknownDataType(Connection conn) throws SQLException {
        assertThrows(ErrorCode.UNKNOWN_DATA_TYPE_1, conn).
            prepareStatement("SELECT * FROM (SELECT ? FROM DUAL)");
        PreparedStatement prep = conn.prepareStatement("SELECT -?");
        prep.setInt(1, 1);
        prep.execute();
        prep = conn.prepareStatement("SELECT ?-?");
        prep.setInt(1, 1);
        prep.setInt(2, 2);
        prep.execute();
    }
View Full Code Here

        prep.setInt(1, 1);
        prep.execute();
        prep = conn.prepareStatement("SELECT ?-?");
        prep.setInt(1, 1);
        prep.setInt(2, 2);
        prep.execute();
    }

    private void testCancelReuse(Connection conn) throws Exception {
        conn.createStatement().execute("CREATE ALIAS SLEEP FOR \"java.lang.Thread.sleep\"");
        // sleep for 10 seconds
View Full Code Here

        stat.execute("create table test(id int primary key, b blob, c clob)");
        PreparedStatement prep = conn.prepareStatement("insert into test values(?, ?, ?)");
        prep.setInt(1, 0);
        prep.setNull(2, Types.BLOB);
        prep.setNull(3, Types.CLOB);
        prep.execute();
        prep.setInt(1, 1);
        prep.setBytes(2, new byte[0]);
        prep.setString(3, "");
        prep.execute();
        prep.setInt(1, 2);
View Full Code Here

        final PreparedStatement prep = conn.prepareStatement("SELECT SLEEP(?) FROM SYSTEM_RANGE(1, 10000) LIMIT ?");
        prep.setInt(1, 1);
        prep.setInt(2, 10000);
        Task t = new Task() {
            public void call() throws SQLException {
                prep.execute();
            }
        };
        t.execute();
        Thread.sleep(100);
        prep.cancel();
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.