Package org.eclipse.net4j.db

# Class StatementBatcher

java.lang.Object
org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.db.StatementBatcher

All Implemented Interfaces:
  `AutoCloseable`, `Consumer<String>`, `org.eclipse.net4j.util.event.INotifier`, `org.eclipse.net4j.util.event.INotifier.INotifier2`

public class StatementBatcher extends org.eclipse.net4j.util.event.Notifier implements AutoCloseable, Consumer<String>
A helper for batching SQL statements.

Since:
  4.13
Author:
  Eike Stepper

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static final class`
`StatementBatcher.BatchEvent`
`static final class`
`StatementBatcher.CloseEvent`
`static final class`
`StatementBatcher.ResultEvent`

## Nested classes/interfaces inherited from class org.eclipse.net4j.util.event.Notifier

`org.eclipse.net4j.util.event.Notifier.Cancelation`

## Nested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier

`org.eclipse.net4j.util.event.INotifier.INotifier2`

## Constructor Summary

Constructors
Constructor
Description
`StatementBatcher(Connection connection)`
`StatementBatcher(Connection connection, int batchSize)`

## Method Summary

Modifier and Type
Method
Description
`final void`
`accept(String sql)`
`int`
`batch(String sql)`
`void`
`close()`
`protected final int`
`doExecuteBatch()`
`protected final Statement`
`ensureStatement()`
`final int`
`getBatchCount()`
`final int`
`getBatchSize()`
`final Connection`
`getConnection()`
`final Statement`
`getStatement()`
`final int`
`getTotalUpdateCount()`
`final boolean`
`isClosed()`

### Methods inherited from class org.eclipse.net4j.util.event.Notifier

`addListener, addUniqueListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListener`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.function.Consumer

`andThen`

## Constructor Details

### StatementBatcher

public StatementBatcher(Connection connection)

### StatementBatcher

public StatementBatcher(Connection connection, int batchSize)

## Method Details

### getConnection

public final Connection getConnection()

### getStatement

public final Statement getStatement()

### getBatchSize

public final int getBatchSize()

### getBatchCount

public final int getBatchCount()

### getTotalUpdateCount

public final int getTotalUpdateCount()

### accept

public final void accept(String sql)

Specified by:
  `accept` in interface `Consumer<String>`

### batch

public int batch(String sql)

### isClosed

public final boolean isClosed()

### close

public void close()

Specified by:
  `close` in interface `AutoCloseable`

### ensureStatement

protected final Statement ensureStatement() throws SQLException

Throws:
  `SQLException`

### doExecuteBatch

protected final int doExecuteBatch()