Package java.sql

Examples of java.sql.Statement.executeBatch()


        stmt.addBatch("create table ddltsttable1(c1 int)");
        stmt.addBatch("create procedure ddlinteg() language java " +
            "parameter style java external name 'java.lang.Integer'");
        stmt.addBatch("create table ddltable2(c1 date)");
        int expectedCount[] = {0,0,0};
        assertBatchUpdateCounts(expectedCount, stmt.executeBatch());
        ResultSet rs = stmt.executeQuery(
            "select count(*) from SYS.SYSTABLES where tablename like 'DDL%'");
        JDBC.assertSingleValueResultSet(rs, "2");
        rs = stmt.executeQuery(
            "select count(*) from SYS.SYSALIASES where alias like 'DDL%'");
View Full Code Here


        Statement stmt = createStatement();
        // try executing a batch which nothing in it. Should work.
        println("Positive Statement: clear the batch and run the empty batch");
        stmt.clearBatch();
        assertBatchUpdateCounts(new int[0], stmt.executeBatch());

        stmt.close();
        commit();
    }
View Full Code Here

        Statement stmt = createStatement();
        println("Positive Statement: testing 1 statement batch");
        stmt.addBatch("insert into t1 values(2)");

        assertBatchUpdateCounts(new int[] {1}, stmt.executeBatch());
        stmt.close();
        commit();
    }
   
    // try executing a batch with 3 different statements in it.
View Full Code Here

        println("Positive Statement: testing 2 inserts and 1 update batch");
        stmt.addBatch("insert into t1 values(2)");
        stmt.addBatch("update t1 set c1=4");
        stmt.addBatch("insert into t1 values(3)");

        assertBatchUpdateCounts(new int[] {1,1,1}, stmt.executeBatch());
       
        rs = stmt.executeQuery("select count(*) from t1 where c1=2");
        rs.next();
        assertEquals("expect 0 rows with c1 = 2", 0, rs.getInt(1));
        rs.close();
View Full Code Here

        println("Positive Statement: 1000 statements batch");
        for (int i=0; i<1000; i++){
            stmt.addBatch("insert into t1 values(1)");
        }
        updateCount = stmt.executeBatch();
       
        int[] expectedUpdateCount = new int[1000];
        Arrays.fill(expectedUpdateCount, 1);
        assertBatchUpdateCounts(expectedUpdateCount, updateCount);
       
View Full Code Here

        // try batch with autocommit true
        println("Positive Statement: stmt testing with autocommit true");
        stmt.addBatch("insert into t1 values(1)");
        stmt.addBatch("insert into t1 values(1)");
        stmt.addBatch("delete from t1");
        assertBatchUpdateCounts(new int[] {1,1,2}, stmt.executeBatch());

        assertTableRowCount("T1", 0);
       
        stmt.close();
    }
View Full Code Here

        stmt.addBatch("insert into t1 values(2)");
        stmt.addBatch("insert into t1 values(2)");
        stmt.clearBatch();

        // Batch should be cleared, there should be no update count
        assertBatchUpdateCounts(new int[0], stmt.executeBatch());
        assertTableRowCount("T1", 0);

        println("Positive Statement: add 3 statements, clear batch, " +
            "add 3 more statements and execute batch");
        stmt.addBatch("insert into t1 values(2)");
View Full Code Here

        stmt.clearBatch();
        stmt.addBatch("insert into t1 values(2)");
        stmt.addBatch("insert into t1 values(2)");
        stmt.addBatch("insert into t1 values(2)");

        assertBatchUpdateCounts(new int[] {1,1,1}, stmt.executeBatch());
        assertTableRowCount("T1", 3);

        stmt.close();
        commit();
    }
View Full Code Here

            }
        }
        else if (usingDerbyNetClient())
        {
            stmt.executeQuery("SELECT * FROM SYS.SYSTABLES");
            updateCount = stmt.executeBatch();
            assertBatchUpdateCounts(new int[] {1}, updateCount);
            // set to same spot as embedded
            rollback();
        }

View Full Code Here

            {
                assertBatchExecuteError("XJ208", stmt, new int[] {1,1,-3});
            }
            else if (usingEmbedded())
            {
                updateCount = stmt.executeBatch();
                fail("Expected executeBatch to fail");
            }
        } catch (SQLException sqle) {
            /* Check to be sure the exception is the MIDDLE_OF_BATCH */
            if (usingEmbedded())
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.