public class BatchInserter extends Object
| Constructor and Description |
|---|
BatchInserter(PreparedStatement ps,
Class<?>[] classes,
int[] targetSqlTypes)
Creates an instance of
BatchInserter. |
| Modifier and Type | Method and Description |
|---|---|
void |
addData(Object... obs)
Adds the given data to the batch.
|
void |
commitTail()
Commits to the database what has been added to the batch but not yet been
committed.
|
public BatchInserter(PreparedStatement ps, Class<?>[] classes, int[] targetSqlTypes) throws SQLException
Creates an instance of BatchInserter. The connection which
was used to create ps is set to
autoCommit=false. This should not be changed while you want
to do batch inserts. Calling commitTail resets the
autoCommit value.
ps - the PreparedStatement formulating the insertionclasses - an array of classes reflecting the arguments which will be
passed to ps; is used for consistency checksSQLExceptionpublic void addData(Object... obs) throws SQLException
Adds the given data to the batch.
The given objects must correspond to the classes array given in the constructor in length and class types. An IllegalArgumentException will be risen otherwise.
obs - SQLExceptionpublic void commitTail()
throws SQLException
Commits to the database what has been added to the batch but not yet been committed.
Sets the autoCommit value of the connection of the passed
PreparedStatement back to what it was when creating the
BatchInserter. Thus, the BatchInserter should
no longer be used.
SQLExceptionCopyright © 2018 JULIE Lab, Germany. All rights reserved.