Package java.sql

Examples of java.sql.PreparedStatement.executeBatch()


            for(int i = 0; i < params.length; i++) {
                fillStatement(stmt, params[i]);
                stmt.addBatch();
            }
            verboseQuery(sql, (Object[]) params);
            rows = stmt.executeBatch();
        } catch (SQLException e) {
            rethrow(e, sql, (Object[]) params);
        } finally {
            close(stmt);
        }
View Full Code Here


    value1.setMultiValued(true);
    value1.setBindValue(true);
    value1.setValue(Arrays.asList(2, 3));
    Connection connection = Mockito.mock(Connection.class);
    PreparedStatement p = Mockito.mock(PreparedStatement.class);
    Mockito.stub(p.executeBatch()).toReturn(new int [] {1, 1});
    Mockito.stub(connection.prepareStatement("INSERT INTO SmallA (IntKey, IntNum) VALUES (?, ?)")).toReturn(p); //$NON-NLS-1$
   
    JDBCExecutionFactory config = new JDBCExecutionFactory();
   
    JDBCUpdateExecution updateExecution = new JDBCUpdateExecution(command, connection, Mockito.mock(ExecutionContext.class), config);
View Full Code Here

    values.add(Arrays.asList(2, 3));
    command.setValueSource(new IteratorValueSource(values.iterator(), 2));
   
    Connection connection = Mockito.mock(Connection.class);
    PreparedStatement p = Mockito.mock(PreparedStatement.class);
    Mockito.stub(p.executeBatch()).toReturn(new int [] {1, 1});
    Mockito.stub(connection.prepareStatement("INSERT INTO SmallA (IntKey, IntNum) VALUES (?, ?)")).toReturn(p); //$NON-NLS-1$
   
    JDBCExecutionFactory config = new JDBCExecutionFactory();
   
    JDBCUpdateExecution updateExecution = new JDBCUpdateExecution(command, connection, Mockito.mock(ExecutionContext.class), config);
View Full Code Here

        }
        Reader x = new StringReader(buff.toString());
        prep1.setCharacterStream(2, x, 10000);
        prep1.setLong(3, 1);
        prep1.addBatch();
        prep1.executeBatch();
        prep1.close();
        conn0.getAutoCommit();
        conn0.getAutoCommit();
        conn0.commit();
        conn0.isClosed();
View Full Code Here

        for (int i = 0; i < 3; i++) {
            prep.setInt(1, i);
            prep.setCharacterStream(2, new StringReader(getString(i)), -1);
            prep.addBatch();
        }
        prep.executeBatch();
        rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID");
        for (int i = 0; i < 3; i++) {
            assertTrue(rs.next());
            assertEquals(getString(i), rs.getString(2));
        }
View Full Code Here

        prep.setString(1, "TEST_X");
        prep.addBatch();
        prep.setString(1, "TEST_Y");
        prep.addBatch();
        try {
            prep.executeBatch();
        } catch (SQLException e) {
            assertContains(e.toString(), "TEST_Y");
            e = e.getNextException();
            assertTrue(e != null);
            assertContains(e.toString(), "TEST_Y");
View Full Code Here

        batchStmt.setString(2, (String)recipients.get(i));
        batchStmt.setString(3, type);
        batchStmt.addBatch();
      }
     
      batchResult = batchStmt.executeBatch();
    } catch (Exception e) {
      System.out.println("[Exception][CVDal.batchProcess] Exception Thrown: " + e);
      e.printStackTrace();
    }
    return batchResult;
View Full Code Here

            st.setString(1, "name01_" + i);
            st.setString(2, "name02_" + i);
            st.setBinaryStream(3, bais, blob.length);
            st.addBatch();
         }
         st.executeBatch();
         conn.commit();
         long t1 = System.currentTimeMillis();
         long dt = t1-t0;
         log.info("batch statements='" + nmax + "' took '" + dt + "' ms (per statement: " + dt/nmax + ")");
         pool.update("delete from PERFORM");
View Full Code Here

            preStatement.setBinaryStream(BLOB, blob_stream, blob.length); //(int)sizeInBytes);
            //preStatement.setBytes(7, blob);
            if (log.isLoggable(Level.FINE)) log.fine(preStatement.toString());
            preStatement.addBatch();
         }
         int[] ret = preStatement.executeBatch();
         if (!conn.getAutoCommit()) conn.commit();
         return ret;
       }
      catch (Throwable ex) {
         success = false;
View Full Code Here

           
            ps.addBatch();
        }
       
        //executing the batch...
        ps.executeBatch();

        conn.commit();
         
        log.info("Test JDBC inserts successfuly executed.");
  }
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.