Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.BatchPreparedStatementSetter


      logger.debug("Executing statement " + getInsertString() + " with batch of size: " + batchValues.length);
    }
    final int[] columnTypes = getInsertTypes();
    int[] updateCounts = jdbcTemplate.batchUpdate(
        getInsertString(),
        new BatchPreparedStatementSetter() {

          public void setValues(PreparedStatement ps, int i) throws SQLException {
            List<Object> values = batchValues[i];
            setParameterValues(ps, values, columnTypes);
          }
View Full Code Here



  private int[] doExecuteBatchUpdate(String sql, final List<Object[]> batchValues, final int[] columnTypes) {
    return getJdbcOperations().batchUpdate(
        sql,
        new BatchPreparedStatementSetter() {

          public void setValues(PreparedStatement ps, int i) throws SQLException {
            Object[] values = batchValues.get(i);
            doSetStatementParameters(values, ps, columnTypes);
          }
View Full Code Here

    }
    final ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
    String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, batchArgs[0]);
    return getJdbcOperations().batchUpdate(
        sqlToUse,
        new BatchPreparedStatementSetter() {

          public void setValues(PreparedStatement ps, int i) throws SQLException {
            Object[] values = NamedParameterUtils.buildValueArray(parsedSql, batchArgs[i], null);
            int[] columnTypes = NamedParameterUtils.buildSqlTypeArray(parsedSql, batchArgs[i]);
            doSetStatementParameters(values, ps, columnTypes);
View Full Code Here

      return new int[0];
    }
   
    int[] rowsAffected = getJdbcTemplate().batchUpdate(
        getSql(),
        new BatchPreparedStatementSetter() {
          public int getBatchSize() {
            return parameterQueue.size();
          }
          public void setValues(PreparedStatement ps, int index) throws SQLException {
            Object[] params = (Object[]) parameterQueue.removeFirst();
View Full Code Here

        final long batchSize = to - from + 1;
        final int policySeriesId = series.getId();
        final int policyTypeId = series.getPolicyType().getId();
        final String sqlInsert = "INSERT INTO BlankPolicy(issuedToAgent, inventoryDate," +
                " number, series_id, policyType_id, inventoryPolicyState, agent_passport_series) VALUES(?,?,?,?,?,?,?)";
        jdbcTemplate.batchUpdate(sqlInsert, new BatchPreparedStatementSetter() {

            private java.sql.Date currentDate = new java.sql.Date(new Date().getTime());

            @Override
            public void setValues(PreparedStatement ps, int i) throws SQLException {
View Full Code Here

     *
     * @param acl containing the ACEs to insert
     */
    protected void createEntries(final MutableAcl acl) {
        jdbcTemplate.batchUpdate(insertEntry,
            new BatchPreparedStatementSetter() {
                public int getBatchSize() {
                    return acl.getEntries().length;
                }

                public void setValues(PreparedStatement stmt, int i)
View Full Code Here

   * @param argsList
   *
   * */
  protected int[] batchUpdate(final String sql, final List<Object[]> argsList) {
    Assert.notEmpty(argsList, "args can not be empty while batch insert");
    return jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
      @Override
      public void setValues(PreparedStatement ps, int i) throws SQLException {
        Object[] args = argsList.get(i);
        int length = args.length;
        for (int j = 1; j <= length; j++) {
View Full Code Here

  private BatchPreparedStatementSetterCreator() {
   
  }
 
  public static BatchPreparedStatementSetter createBatchPreparedStatementSetter(final List<Object[]> argsList) {
    BatchPreparedStatementSetter setter = new BatchPreparedStatementSetter() {

      @Override
      public void setValues(PreparedStatement ps, int i) throws SQLException {
        Object[] args = argsList.get(i);
        if (args != null) {
View Full Code Here

    }
  }

  @Override
  public int[] batchUpdate(String sql, List<Object[]> argsList, KeyHolder generatedKeyHolder) {
    BatchPreparedStatementSetter pss = getBatchPreparedStatementSetter(argsList);
    PreparedStatementCallback<int[]> action = getPreparedStatementCallback(pss, generatedKeyHolder);
    boolean returnKeys = (generatedKeyHolder != null);
    PreparedStatementCreator psc = getPreparedStatementCreator(sql, returnKeys);
    return jdbcTemplate.execute(psc, action);
  }
View Full Code Here

                                    try {
                                        failedDatas.clear(); // 先清理
                                        processedDatas.clear();
                                        interceptor.transactionBegin(context, splitDatas, dbDialect);
                                        JdbcTemplate template = dbDialect.getJdbcTemplate();
                                        int[] affects = template.batchUpdate(sql, new BatchPreparedStatementSetter() {

                                            public void setValues(PreparedStatement ps, int idx) throws SQLException {
                                                doPreparedStatement(ps, dbDialect, lobCreator, splitDatas.get(idx));
                                            }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.BatchPreparedStatementSetter

Copyright © 2018 www.massapicom. 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.