Class MultiRowPreparedStatementInsert
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.jdbc.insert.MultiRowPreparedStatementInsert
Sample Generated SQL:
INSERT INTO tableName (col1, col2, col3) VALUES
(?, ?, ?),
(?, ?, ?),
(?, ?, ?),...
-
Field Summary
Fields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBatch()Adds the applied values to the batch; called instead ofIInsert.executeUpdate()when the writer is batching.addExceptionProperties(DataException exception) Adds this object's current state to aDataException.protected StringbuildSql(JdbcWriter writer, Record record, int rowCount) Returns the INSERT SQL withrowCountrows of?placeholders, using the record's field names as columns.clone()Returns a new, unprepared copy with the same settings;JdbcMultiWriteruses one for each connection.voidclose()Releases the statement(s); called when the writer is closed.voidExecutes the batch; called each time the writer's batch size is reached and on close if records remain.voidExecutes the statement with the values applied; called after each record when the writer is not batching.booleanReturns true ifIInsert.addBatch()andIInsert.executeBatch()are supported; otherwiseJdbcWriter.setBatchSize(int)rejects batch sizes above 1.booleanisDebug()Indicates if the generated SQL should be logged (default false).voidprepare(JdbcWriter writer, Record record) Called once, with the first record written, to generate the SQL and create the statement(s).setDebug(boolean debug) Set totrueto log generated SQL (default false).voidsetValues(JdbcWriter writer, Record record) Applies the record's values to the pending statement; called for every record written.
-
Constructor Details
-
MultiRowPreparedStatementInsert
public MultiRowPreparedStatementInsert()
-
-
Method Details
-
isDebug
public boolean isDebug()Description copied from interface:IInsertIndicates if the generated SQL should be logged (default false). -
setDebug
Description copied from interface:IInsertSet totrueto log generated SQL (default false). -
buildSql
Returns the INSERT SQL withrowCountrows of?placeholders, using the record's field names as columns.- Throws:
Throwable
-
prepare
Description copied from interface:IInsertCalled once, with the first record written, to generate the SQL and create the statement(s). -
setValues
Description copied from interface:IInsertApplies the record's values to the pending statement; called for every record written. -
executeUpdate
Description copied from interface:IInsertExecutes the statement with the values applied; called after each record when the writer is not batching.- Specified by:
executeUpdatein interfaceIInsert- Throws:
Throwable
-
isBatchSupported
public boolean isBatchSupported()Description copied from interface:IInsertReturns true ifIInsert.addBatch()andIInsert.executeBatch()are supported; otherwiseJdbcWriter.setBatchSize(int)rejects batch sizes above 1.- Specified by:
isBatchSupportedin interfaceIInsert
-
addBatch
Description copied from interface:IInsertAdds the applied values to the batch; called instead ofIInsert.executeUpdate()when the writer is batching. -
executeBatch
Description copied from interface:IInsertExecutes the batch; called each time the writer's batch size is reached and on close if records remain.- Specified by:
executeBatchin interfaceIInsert- Throws:
Throwable
-
close
Description copied from interface:IInsertReleases the statement(s); called when the writer is closed. -
clone
Description copied from interface:IInsertReturns a new, unprepared copy with the same settings;JdbcMultiWriteruses one for each connection. -
addExceptionProperties
Description copied from class:DataObjectAdds this object's current state to aDataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.- Specified by:
addExceptionPropertiesin interfaceIInsert- Overrides:
addExceptionPropertiesin classDataObject
-