Package java.sql

Examples of java.sql.Statement.executeBatch()


        // fill batch:
        for (int i=0; i < 10; i++) {
            s.addBatch("insert into tmp values (" + i + ")");
        }

        s.executeBatch(); // should work OK, since no interrupt present

        // refill batch:
        for (int i=0; i < 10; i++) {
            s.addBatch("insert into tmp values (" + i + ")");
        }
View Full Code Here


            s.addBatch("insert into tmp values (" + i + ")");
        }

        try {
            Thread.currentThread().interrupt();
            s.executeBatch();
            fail("expected CONN_INTERRUPT");
        } catch (SQLException e) {
            assertSQLState("expected CONN_INTERRUPT", "08000", e);
            // assertTrue(c.isClosed()); // DERBY-4993
            assertTrue(Thread.interrupted());
View Full Code Here

            if (queryEnds) {
                stmt.addBatch(query.toString());
                query.setLength(0);
            }
        }
        stmt.executeBatch();
       
    }
    /**
     * Execute the specified query
     * If the SQL connection if not open, it will be opened automatically
View Full Code Here

        s.execute("delete from t1");
        s.addBatch("insert into t1 values(1,1)");
        s.addBatch("insert into t1 values(2,2)");
        Savepoint savepoint1 = con.setSavepoint();
        s.addBatch("insert into t1 values(3,3)");
        s.executeBatch();
        con.rollback(savepoint1);

        assertTableRowCount("T1", 0);
        con.rollback();
    }
View Full Code Here

                for (Iterator i = statementList.iterator(); i.hasNext();) {
                    String sqlStatement = (String) i.next();
                    statement.addBatch(sqlStatement);
                }

                statement.executeBatch();
            }

        } catch (SQLException e) {
            e.printStackTrace();
            System.out
View Full Code Here

                for (Iterator i = statementList.iterator(); i.hasNext();) {
                    String sqlStatement = (String) i.next();
                    statement.addBatch(sqlStatement);
                }

                statement.executeBatch();
            }

        } catch (SQLException e) {
            e.printStackTrace();
            System.out
View Full Code Here

      st = dbcon.createStatement();
      st.addBatch(sql);
      st.addBatch(sql2);
      st.addBatch(sql3);
      st.addBatch(sql4);
      int[] res = st.executeBatch();

      System.out.println(res);
    } catch (SQLException e) {
      LOG.error(StringUtils.stringifyException(e));
    }
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("select count(*) from t");
            stmt.addBatch("upsert into t values ('a', 4)");
            ResultSet rs = stmt.executeQuery("select count(*) from t");
            assertTrue(rs.next());
            assertEquals(2, rs.getInt(1));
            int[] result = stmt.executeBatch();
            assertEquals(3,result.length);
            assertEquals(result[0], 1);
            assertEquals(result[1], -2);
            assertEquals(result[2], 1);
            conn.commit();
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

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.