Class MultiRowStatementInsert
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.jdbc.insert.MultiRowStatementInsert
- Direct Known Subclasses:
OracleMultiRowStatementInsert
Sample Generated SQL:
INSERT INTO tableName (col1, col2, col3) VALUES
(val1, val2, val3),
(val1, val2, val3),
(val1, val2, val3),..
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final SimpleDateFormatprotected final SimpleDateFormatprotected final SimpleDateFormatFields 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.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.protected StringgetBigDecimalLiteral(BigDecimal value) protected StringgetBigIntegerLiteral(BigInteger value) protected StringgetBooleanLiteral(boolean value) ReturnsTRUEorFALSE.protected StringgetByteLiteral(byte value) protected StringgetBytesLiteral(byte[] value) protected StringgetDateLiteral(Date value) Returns the value as a JDBC date escape,{d 'yyyy-MM-dd'}.protected StringgetDateTimeLiteral(Date value) Returns the value as a JDBC timestamp escape,{ts 'yyyy-MM-dd HH:mm:ss.SSS'}.protected StringgetDoubleLiteral(double value) protected StringgetFloatLiteral(float value) protected StringBuilderReturns the SQL buffer holding the prefix followed by the rows of values not yet executed.protected StringReturns the SQL that precedes the rows of values; the SQL buffer is truncated back to its length after each execution.protected Statementprotected StringgetIntLiteral(int value) protected StringgetLongLiteral(long value) protected intprotected StringgetShortLiteral(short value) protected StringgetSqlValueLiteral(Field field) Returns the field's value as a SQL literal (nullfor null fields), delegating to the literal method for its type.protected StringgetStringLiteral(String value) Returns the value in single quotes with embedded single quotes doubled; also used for UUID, CHAR and any field type without its own literal method.protected StringgetTimeLiteral(Time value) Returns the value as a JDBC time escape,{t 'HH:mm:ss.SSS'}.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).protected MultiRowStatementInsertsetInsertSqlPrefix(String insertSqlPrefix) Sets the SQL that precedes the rows of values; the SQL buffer is truncated back to its length after each execution.protected MultiRowStatementInsertsetInsertStatement(Statement insertStatement) protected MultiRowStatementInsertsetRecordsPendingInsert(int recordsPendingInsert) voidsetValues(JdbcWriter writer, Record record) Applies the record's values to the pending statement; called for every record written.
-
Field Details
-
DATE_TIME_FORMAT
-
DATE_FORMAT
-
TIME_FORMAT
-
-
Constructor Details
-
MultiRowStatementInsert
public MultiRowStatementInsert()
-
-
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). -
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. -
getSqlValueLiteral
Returns the field's value as a SQL literal (nullfor null fields), delegating to the literal method for its type. -
getStringLiteral
Returns the value in single quotes with embedded single quotes doubled; also used for UUID, CHAR and any field type without its own literal method. -
getIntLiteral
-
getLongLiteral
-
getDoubleLiteral
-
getBigIntegerLiteral
-
getBigDecimalLiteral
-
getDateTimeLiteral
Returns the value as a JDBC timestamp escape,{ts 'yyyy-MM-dd HH:mm:ss.SSS'}. -
getBooleanLiteral
ReturnsTRUEorFALSE. -
getByteLiteral
-
getFloatLiteral
-
getShortLiteral
-
getDateLiteral
Returns the value as a JDBC date escape,{d 'yyyy-MM-dd'}. -
getTimeLiteral
Returns the value as a JDBC time escape,{t 'HH:mm:ss.SSS'}. -
getBytesLiteral
-
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
-
getInsertSqlPrefix
Returns the SQL that precedes the rows of values; the SQL buffer is truncated back to its length after each execution. -
setInsertSqlPrefix
Sets the SQL that precedes the rows of values; the SQL buffer is truncated back to its length after each execution. -
getInsertSql
Returns the SQL buffer holding the prefix followed by the rows of values not yet executed. -
getInsertStatement
-
setInsertStatement
-
getRecordsPendingInsert
protected int getRecordsPendingInsert() -
setRecordsPendingInsert
-
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
-