Class StatementBatch<R>

java.lang.Object
io.codemine.java.postgresql.jdbc.StatementBatch<R>

public final class StatementBatch<R> extends Object
Helper for executing statements in batches. All statements must be of the same type (i.e. have the same SQL text and result type) and must not return rows.
  • Constructor Details

    • StatementBatch

      public StatementBatch(Iterable<? extends Statement<R>> statements)
      Create a batch of statements to execute together. All statements must be of the same type (i.e. have the same SQL text and result type) and must not return rows.
      Parameters:
      statements - the statements to execute in batch
  • Method Details

    • of

      @SafeVarargs public static <T> StatementBatch<T> of(Statement<T>... statements)
      Convenience varargs factory method.
      Type Parameters:
      T - the result type
      Parameters:
      statements - the statements to execute in batch
      Returns:
      a new StatementBatch containing the provided statements
    • execute

      public ArrayList<R> execute(Connection connection) throws SQLException
      Execute the batch of statements using the provided JDBC connection. Returns a list of decoded affected-row results, in the same order as the input statements.
      Parameters:
      connection - the JDBC connection to use for batch execution
      Returns:
      a list of decoded results corresponding to each statement in the batch
      Throws:
      SQLException - if a database access error occurs during execution