Package org.jdbi.v3.core.statement
Class Batch
- All Implemented Interfaces:
Closeable,AutoCloseable,Configurable<Batch>
Represents a group of non-prepared statements to be sent to the RDMBS in one "request".
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jdbi.v3.core.statement.BaseStatement
BaseStatement.StatementCustomizerInvocation -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.LoggerFields inherited from class org.jdbi.v3.core.statement.BaseStatement
typedThis -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd a statement to the batch(package private) voidcleanupStatement(Statement statement) (package private) Statementint[]execute()Execute the batch and return the number of rows affected for each batch part.(package private) static SQLExceptionSQLExceptions thrown from batch executions have errors in aSQLException.getNextException()chain, which doesn't print out when you log them.Methods inherited from class org.jdbi.v3.core.statement.BaseStatement
addCustomizers, attachToHandleForCleanup, callCustomizers, cleanUpForException, close, equals, getConfig, getContext, getHandle, hashCodeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jdbi.v3.core.config.Configurable
addCustomizer, configure, define, getConfig, registerArgument, registerArgument, registerArrayType, registerArrayType, registerArrayType, registerArrayType, registerCodecFactory, registerCollector, registerCollector, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerExtension, registerRowMapper, registerRowMapper, registerRowMapper, registerRowMapper, setMapKeyColumn, setMapValueColumn, setSqlArrayArgumentStrategy, setSqlLogger, setSqlParser, setTemplateEngine, setTimingCollector
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
parts
-
-
Constructor Details
-
Batch
-
-
Method Details
-
add
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
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 likeStatement.SUCCESS_NO_INFOorStatement.EXECUTE_FAILED.- Returns:
- the number of rows affected per batch part
- See Also:
-
createStatement
- Throws:
SQLException
-
cleanupStatement
- Throws:
SQLException
-
mungeBatchException
SQLExceptions thrown from batch executions have errors in aSQLException.getNextException()chain, which doesn't print out when you log them. Convert them to beThrowable.addSuppressed(Throwable)exceptions, which do print out with common logging frameworks.- Parameters:
e- the exception- Returns:
- the 'suppressed' munged exception change
-