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 TypeMethodDescriptionvoidadd(PreparedStatementSetter preparedStatementSetter) Add a new row to the batch.voidaddBatch()Add a new row to the batch.voidclose()Get thePreparedStatementthat 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 thePreparedStatementthat is used for the batch insert. Use this to set values on thePreparedStatementbefore callingaddBatch().Use this method if you want to set values on the
PreparedStatementdirectly and you need more control. Prefer usingadd(PreparedStatementSetter)if possible.- Returns:
- the
PreparedStatementused for the batch insert
-
addBatch
Add a new row to the batch. Only call this method if you have set all values on thePreparedStatementretrieved fromstatement.Don't call this if you use
add(PreparedStatementSetter). -
close
- Specified by:
closein interfaceAutoCloseable
-