Package java.sql

Examples of java.sql.Statement.clearBatch()


        println("Positive Statement: add 3 statements, clear batch, " +
            "add 3 more statements and execute batch");
        stmt.addBatch("insert into t1 values(2)");
        stmt.addBatch("insert into t1 values(2)");
        stmt.addBatch("insert into t1 values(2)");
        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());
View Full Code Here


            assertBatchExecuteError("XJ208",stmt, new long[] {-3,1});          
            // pull level with embedded situation
            rollback();
        }
        // do clearBatch so we can proceed
        stmt.clearBatch();

        assertTableRowCount("T1", 0);

        // trying executeQuery after addBatch
        println("Negative Statement: " +
View Full Code Here

                fail("Expected executeQuerywith embedded");
            } catch (SQLException sqle) {
                /* Check to be sure the exception is the MIDDLE_OF_BATCH */
                assertSQLState("XJ068", sqle);
                // do clearBatch so we can proceed
                stmt.clearBatch();
            }
        }
        else if (usingDerbyNetClient())
        {
            stmt.executeQuery("SELECT * FROM SYS.SYSTABLES");
View Full Code Here

            if (usingEmbedded())
                assertSQLState("XJ068", sqle);
            else if (usingDerbyNetClient())
                assertSQLState("XJ208", sqle);
           
            stmt.clearBatch();
        }
       
        assertTableRowCount("T1",
                usingEmbedded() ? 0 : 3);
View Full Code Here

            }
        }
        conn.rollback();
        conn2.rollback();
        stmt.clearBatch();
        stmt2.clearBatch();
        stmt.close();
        stmt2.close();
        commit();
        conn2.close();
    }
View Full Code Here

        System.out.println("Statement Test failed (24)");
      }
      catch(SQLException e) { }

      try {
        s.clearBatch();
        System.out.println("Statement Test failed");
      }
      catch(SQLException e) { }

      try {
View Full Code Here

        Statement stm = c.createStatement();
        slurp(stm,
            AbstractServiceTest.class
                .getResourceAsStream("sampledata.sql")); //$NON-NLS-1$
        stm.executeBatch();
        stm.clearBatch();
        stm.close();
        c.commit();
        c.close();

        IS_INIT_DONE = true;
View Full Code Here

  }

  @Test
  public void testEmptyClearBatch() throws Exception {
    Statement stmt = con.createStatement();
    stmt.clearBatch(); // No-op.
    stmt.close();

    PreparedStatement ps = con.prepareStatement("SELECT ?");
    ps.clearBatch(); // No-op.
    ps.close();
View Full Code Here

    Statement stmt = con.createStatement();
    int[] updateCount = stmt.executeBatch();
    assertEquals(0, updateCount.length);

    stmt.addBatch("UPDATE testbatch SET col1 = col1 + 1 WHERE pk = 1");
    stmt.clearBatch();
    updateCount = stmt.executeBatch();
    assertEquals(0, updateCount.length);
    stmt.close();
  }
View Full Code Here

    stmt.addBatch("UPDATE testbatch SET col1 = col1 + 1 WHERE pk = 1");
    assertCol1HasValue(0);
    stmt.addBatch("UPDATE testbatch SET col1 = col1 + 2 WHERE pk = 1");
    assertCol1HasValue(0);
    stmt.clearBatch();
    assertCol1HasValue(0);
    stmt.addBatch("UPDATE testbatch SET col1 = col1 + 4 WHERE pk = 1");
    assertCol1HasValue(0);
    stmt.executeBatch();
    assertCol1HasValue(4);
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.