flush is called or the given batch size has been met.
Note that this class is a non-thread-safe object, in contrast
to all other JDBC operations objects in this package. You need to create
a new instance of it for each use, or call reset before
reuse within the same thread.
flush, reset
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| public static final int | DEFAULT_BATCH_SIZE
Default number of inserts to accumulate before committing a batch (5000). |
| private final Deque | |
| private final List | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | BatchSqlUpdate(DataSource
the DataSource to use to obtain connections ds, String the SQL statement to execute sql)Construct an update object with a given DataSource and SQL. |
| public | BatchSqlUpdate(DataSource
the DataSource to use to obtain connections ds, String the SQL statement to execute sql, int[] the SQL types of the parameters, as defined in the
types)java.sql.Types classConstruct an update object with a given DataSource, SQL and anonymous parameters. |
| public | BatchSqlUpdate(DataSource
the DataSource to use to obtain connections ds, String the SQL statement to execute sql, int[] the SQL types of the parameters, as defined in the
types, int java.sql.Types classthe number of statements that will trigger
an automatic intermediate flush batchSize)Construct an update object with a given DataSource, SQL, anonymous parameters and specifying the maximum number of rows that may be affected. |
| Modifier and Type | Method and Description |
|---|---|
| public int[] | Returns: an array of the number of rows affected by each statementTrigger any queued update operations to be added as a final batch. |
| public int | |
| public int | |
| public int[] | Returns: an array of the number of rows affected by each statementReturn the number of affected rows for all already executed statements. |
| public void | |
| public void | setBatchSize(int batchSize)
Set the number of statements that will trigger an automatic intermediate flush. |
| public void | setTrackRowsAffected(boolean trackRowsAffected)
Set whether to track the rows affected by batch updates performed by this operation object. |
| protected boolean | supportsLobParameters()
Overrides org. BatchSqlUpdate does not support BLOB or CLOB parameters. |
| public int | Returns: the number of rows affected by the update (always -1, meaning "not applicable", as the statement is not actually executed by this method)array of parameter objects params)Overrides org. Overridden version of |
| batchSize | back to summary |
|---|---|
| private int batchSize | |
| DEFAULT_BATCH_SIZE | back to summary |
|---|---|
| public static final int DEFAULT_BATCH_SIZE Default number of inserts to accumulate before committing a batch (5000). | |
| parameterQueue | back to summary |
|---|---|
| private final Deque<Object[]> parameterQueue | |
| rowsAffected | back to summary |
|---|---|
| private final List<Integer> rowsAffected | |
| trackRowsAffected | back to summary |
|---|---|
| private boolean trackRowsAffected | |
| BatchSqlUpdate | back to summary |
|---|---|
| public BatchSqlUpdate() Constructor to allow use as a JavaBean. DataSource and SQL must be supplied before compilation and use.
| |
| BatchSqlUpdate | back to summary |
|---|---|
| public BatchSqlUpdate(DataSource ds, String sql) Construct an update object with a given DataSource and SQL.
| |
| BatchSqlUpdate | back to summary |
|---|---|
| public BatchSqlUpdate(DataSource ds, String sql, int[] types) Construct an update object with a given DataSource, SQL and anonymous parameters.
| |
| BatchSqlUpdate | back to summary |
|---|---|
| public BatchSqlUpdate(DataSource ds, String sql, int[] types, int batchSize) Construct an update object with a given DataSource, SQL, anonymous parameters and specifying the maximum number of rows that may be affected.
| |
| flush | back to summary |
|---|---|
| public int[] flush() Trigger any queued update operations to be added as a final batch.
| |
| getExecutionCount | back to summary |
|---|---|
| public int getExecutionCount() Return the number of already executed statements. | |
| getQueueCount | back to summary |
|---|---|
| public int getQueueCount() Return the current number of statements or statement parameters in the queue. | |
| getRowsAffected | back to summary |
|---|---|
| public int[] getRowsAffected() Return the number of affected rows for all already executed statements.
Accumulates all of
| |
| reset | back to summary |
|---|---|
| public void reset() Reset the statement parameter queue, the rows affected cache, and the execution count. | |
| setBatchSize | back to summary |
|---|---|
| public void setBatchSize(int batchSize) Set the number of statements that will trigger an automatic intermediate
flush. You can also flush already queued statements with an explicit
| |
| setTrackRowsAffected | back to summary |
|---|---|
| public void setTrackRowsAffected(boolean trackRowsAffected) Set whether to track the rows affected by batch updates performed by this operation object. Default is "true". Turn this off to save the memory needed for the list of row counts.
| |
| supportsLobParameters | back to summary |
|---|---|
| protected boolean supportsLobParameters() Overrides org. BatchSqlUpdate does not support BLOB or CLOB parameters.
| |
| update | back to summary |
|---|---|
| public int update(Object... params) throws DataAccessException Overrides org. Overridden version of You need to call | |