Package java.sql

Examples of java.sql.Statement.addBatch()


    @Test
    public void testExecuteWithNonEmptyBatch() throws Exception {
        Connection conn = DriverManager.getConnection(getUrl());
        try {
            Statement stmt = conn.createStatement();
            stmt.addBatch("SELECT * FROM atable");
            stmt.execute("UPSERT INTO atable VALUES('000000000000000','000000000000000')");
            fail();
        } catch (SQLException e) {
            assertEquals(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH.getErrorCode(), e.getErrorCode());
        }
View Full Code Here


        } catch (SQLException e) {
            assertEquals(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH.getErrorCode(), e.getErrorCode());
        }
        try {
            Statement stmt = conn.createStatement();
            stmt.addBatch("SELECT * FROM atable");
            stmt.executeUpdate("UPSERT INTO atable VALUES('000000000000000','000000000000000')");
            fail();
        } catch (SQLException e) {
            assertEquals(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH.getErrorCode(), e.getErrorCode());
        }
View Full Code Here

        } catch (SQLException e) {
            assertEquals(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH.getErrorCode(), e.getErrorCode());
        }
        try {
            PreparedStatement stmt = conn.prepareStatement("UPSERT INTO atable VALUES('000000000000000','000000000000000')");
            stmt.addBatch();
            stmt.execute();
            fail();
        } catch (SQLException e) {
            assertEquals(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH.getErrorCode(), e.getErrorCode());
        }
View Full Code Here

            assertEquals(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH.getErrorCode(), e.getErrorCode());
        }
        conn.close();
        try {
            PreparedStatement stmt = conn.prepareStatement("SELECT * FROM atable");
            stmt.addBatch();
            stmt.executeUpdate();
            fail();
        } catch (SQLException e) {
            assertEquals(SQLExceptionCode.EXECUTE_UPDATE_WITH_NON_EMPTY_BATCH.getErrorCode(), e.getErrorCode());
        }
View Full Code Here

                conn = ds.getConnection();
                statement = conn.createStatement();

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

                statement.executeBatch();
            }
View Full Code Here

        + ",'CD','abcd','efgh','hijk','dothis','likethis','nocomments')";
    Connection dbcon = this.getConnection();
    Statement st;
    try {
      st = dbcon.createStatement();
      st.addBatch(sql);
      st.addBatch(sql2);
      st.addBatch(sql3);
      st.addBatch(sql4);
      int[] res = st.executeBatch();
View Full Code Here

    Connection dbcon = this.getConnection();
    Statement st;
    try {
      st = dbcon.createStatement();
      st.addBatch(sql);
      st.addBatch(sql2);
      st.addBatch(sql3);
      st.addBatch(sql4);
      int[] res = st.executeBatch();

      System.out.println(res);
View Full Code Here

    Statement st;
    try {
      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) {
View Full Code Here

    try {
      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

            switch (databaseType) {
            case derby:
                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
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.