Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.1
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      Description

      From commons-dev:

      Adkins Kendall wrote:
      Has any consideration been given to adding batch update capability?
      For
      instance, the following method could be added to the QueryRunner class:

      /**

      • Execute a batch of SQL INSERT, UPDATE, or DELETE queries.
      • @param conn The connection to use to run the query.
      • @param sql The SQL to execute.
      • @param params An array of query replacement parameters.
      • @return The number of rows updated per statement.
      • @throws SQLException
        */
        public int[] batchUpdate(Connection conn, String sql, Object[][]
        params)
        throws SQLException {
        PreparedStatement stmt = null;
        int[] rows = null;
        try {
        stmt = this.prepareStatement(conn, sql);

      for(int i = 0; i < params.length; i++)

      { this.fillStatement(stmt, params[i]); stmt.addBatch(); }

      rows = stmt.executeBatch();
      } catch (SQLException e)

      { this.rethrow(e, sql, params); }

      finally

      { DbUtils.close(stmt); }

      return rows;
      }

      David Graham wrote:
      I'm fine with adding this to query runner but executeBatch() is marked
      as
      @since 1.3 so we would need to bump DbUtils' minimum Java level. I
      would
      shorten the method name to batch() so we would have query(), update()
      and
      batch() and of course some test cases are needed.

        Activity

        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Henri Yandell made changes -
        Fix Version/s 1.1 [ 12311973 ]
        Henri Yandell made changes -
        Affects Version/s 1.0 Final [ 12311724 ]
        Henri Yandell made changes -
        Project Commons [ 12310458 ] Commons DbUtils [ 12310470 ]
        Affects Version/s 1.0 Final [ 12311651 ]
        Key COM-1168 DBUTILS-13
        Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
        Component/s DbUtils [ 12311110 ]
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 27530 12341320
        David Graham created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            David Graham
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development