Package java.sql

Examples of java.sql.Statement.executeBatch()


            {
                assertBatchExecuteError("XJ208", stmt, new long[] {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


        try
        {
            stmt.executeBatch();
            fail ("Batch is expected to fail");
            updateCount = stmt2.executeBatch();
        } catch (BatchUpdateException bue) {
            /* Ensure the exception is time out while getting lock */
            if (usingEmbedded())
                assertSQLState("40XL1", bue);
            else if (usingDerbyNetClient())
View Full Code Here

            s.addBatch("insert into t values 1");
        }

        BatchUpdateException bue = null;
        try {
            s.executeBatch();
        } catch (BatchUpdateException e) {
            bue = e;
        }
        assertNotNull("Did not get duplicate key exception", bue);
View Full Code Here

        );
        statement = c.createStatement();
        statement.addBatch("INSERT INTO category(bookId,name) VALUES (1,'Theology');");
        statement.addBatch("INSERT INTO category(bookId,name) VALUES (2,'Art History');");
        statement.addBatch("INSERT INTO category(bookId,name) VALUES (3,'Medieval Studies');");
        statement.executeBatch();
       
        // SELECT TEST
        statement = c.createStatement();
        statement.execute("SELECT COUNT(bookId) FROM category;");
        ResultSet resultSet = statement.getResultSet();
View Full Code Here

                sql = "LOCK TABLE " + QueueContants.TABLE_NAME_MAXID + " IN EXCLUSIVE MODE";
                String sql2 = "LOCK TABLE " + QueueContants.TABLE_NAME_MINID + " IN EXCLUSIVE MODE";
                stmt = connection.createStatement();
                stmt.addBatch(sql);
                stmt.addBatch(sql2);
                stmt.executeBatch();
                break;
            case mysql:
                sql = "lock tables " + QueueContants.TABLE_NAME_MAXID + " write" + "," + QueueContants.TABLE_NAME_MINID
                        + " write";
                stmt = connection.createStatement();
View Full Code Here

        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 CAST(tablename AS VARCHAR(128)) like 'DDL%'");
        JDBC.assertSingleValueResultSet(rs, "2");
        rs = stmt.executeQuery(
            "select count(*) from SYS.SYSALIASES where CAST(alias AS VARCHAR(128)) 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

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.