Class Batch

java.lang.Object
org.jdbi.v3.core.statement.Batch
All Implemented Interfaces:
Closeable, AutoCloseable, Configurable<Batch>

public class Batch extends Object
Represents a group of non-prepared statements to be sent to the RDMBS in one "request".
  • Constructor Details Link icon

    • Batch Link icon

      public Batch(Handle handle)
  • Method Details Link icon

    • add Link icon

      public Batch add(String sql)
      Add a statement to the batch
      Parameters:
      sql - SQL to be added to the batch, possibly a named statement
      Returns:
      the same Batch statement
    • execute Link icon

      public int[] execute()
      Execute the batch and return the number of rows affected for each batch part. Note that some database drivers might return special values like Statement.SUCCESS_NO_INFO or Statement.EXECUTE_FAILED.
      Returns:
      the number of rows affected per batch part
      See Also:
    • getHandle Link icon

      public final Handle getHandle()
    • getConfig Link icon

      public ConfigRegistry getConfig()
      Description copied from interface: Configurable
      Returns the configuration registry associated with this object.
      Specified by:
      getConfig in interface Configurable<This>
      Returns:
      the configuration registry associated with this object.
    • getContext Link icon

      public final StatementContext getContext()
      Returns the statement context associated with this statement.
      Returns:
      the statement context associated with this statement.
    • attachToHandleForCleanup Link icon

      @Beta public final Batch attachToHandleForCleanup()
      Registers with the handle for cleaning when the handle is closed.
      There are some situations where Statements need to be cleaned up to avoid resource leaks. This method registers the current Statement it with the Handle. If the statement or the context are cleaned by themselves, it will automatically unregister, so in normal operations, resources should not pool for cleanup with the Handle.
      Since:
      3.35.0
    • close Link icon

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • equals Link icon

      public final boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode Link icon

      public final int hashCode()
      Overrides:
      hashCode in class Object