java.lang.Object
org.itsallcode.jdbc.batch.PreparedStatementBatch
- All Implemented Interfaces:
AutoCloseable
Direct batch insert using
PreparedStatement
. Create a new instance
using SimpleConnection.preparedStatementBatch()
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(PreparedStatementSetter preparedStatementSetter) Add a new row to the batch.void
addBatch()
Add a new row to the batch.void
close()
Get thePreparedStatement
that is used for the batch insert.
-
Method Details
-
add
Add a new row to the batch.Important: This method automatically calls
PreparedStatement.addBatch()
. No need to call it separately.- Parameters:
preparedStatementSetter
- prepared statement setter that is used for setting row values of thePreparedStatement
.
-
getStatement
Get thePreparedStatement
that is used for the batch insert. Use this to set values on thePreparedStatement
before callingaddBatch()
.Use this method if you want to set values on the
PreparedStatement
directly and you need more control. Prefer usingadd(PreparedStatementSetter)
if possible.- Returns:
- the
PreparedStatement
used for the batch insert
-
addBatch
Add a new row to the batch. Only call this method if you have set all values on thePreparedStatement
retrieved fromstatement
.Don't call this if you use
add(PreparedStatementSetter)
. -
close
- Specified by:
close
in interfaceAutoCloseable
-