Package org.jdbi.v3.core.statement
Class Batch
- java.lang.Object
-
- org.jdbi.v3.core.statement.BaseStatement<Batch>
-
- org.jdbi.v3.core.statement.Batch
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,Configurable<Batch>
public class Batch extends BaseStatement<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
Fields Modifier and Type Field Description private static org.slf4j.LoggerLOGprivate java.util.List<java.lang.String>parts-
Fields inherited from class org.jdbi.v3.core.statement.BaseStatement
typedThis
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Batchadd(java.lang.String sql)Add a statement to the batch(package private) voidcleanupStatement(java.sql.Statement statement)(package private) java.sql.StatementcreateStatement()int[]execute()Execute the batch and return the number of rows affected for each batch part.(package private) static java.sql.SQLExceptionmungeBatchException(java.sql.SQLException e)SQLExceptions 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, hashCode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods 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
-
-
-
-
Constructor Detail
-
Batch
public Batch(Handle handle)
-
-
Method Detail
-
add
public Batch add(java.lang.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
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:
Statement.executeBatch()
-
createStatement
java.sql.Statement createStatement() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
cleanupStatement
void cleanupStatement(java.sql.Statement statement) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
mungeBatchException
static java.sql.SQLException mungeBatchException(java.sql.SQLException e)
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
-
-