public class MySqlUpsertWriter extends MySqlInsertWriter
DataEndpoint.StatebatchedInserts, batchSize, pretty, tableNamecurrentRecordlastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEYBUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEid, log, name, TIMESTAMP_FORMAT| Constructor and Description |
|---|
MySqlUpsertWriter(String table,
File file) |
MySqlUpsertWriter(String table,
File file,
boolean append) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Indicates that this endpoint has finished reading or writing.
|
MySqlUpsertWriter |
setBatchSize(int batchSize)
Sets the number of records to chunk together in batch upserts.
|
MySqlUpsertWriter |
setPretty(boolean pretty)
Indicates if line breaks and indentations should be added to output upsert statement (default false).
Example output (pretty = true): INSERT INTO `tableName` (`col1`, `col2`) |
protected void |
writeRecord(Record record) |
addExceptionProperties, getBatchSize, getSqlValueLiteral, getTableName, isBatchMode, isPretty, setFieldNamesInFirstRowgetFile, getWriter, isAppend, isAutoCloseWriter, isFieldNamesInFirstRow, isFlushOnWrite, setAutoCloseWriter, setFlushOnWrite, writeopen, writeImplavailable, getNestedEndpoint, getNestedWriter, getRootEndpoint, getRootWriter, getWriterdecrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toStringaddElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescriptionprotected void writeRecord(Record record) throws Throwable
writeRecord in class MySqlInsertWriterThrowablepublic void close()
DataEndpointclose in class MySqlInsertWriterpublic MySqlUpsertWriter setPretty(boolean pretty)
INSERT INTO `tableName` (`col1`, `col2`)
VALUES (val1, val2),
(val1, val2),
(val1, val2)
ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);
INSERT INTO `tableName` (`col1`, `col2`) VALUES (val1, val2), (val1, val2), (val1, val2) ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);setPretty in class MySqlInsertWriterpublic MySqlUpsertWriter setBatchSize(int batchSize)
INSERT INTO `tableName` (`col1`, `col2`)
VALUES (val1, val2),
(val1, val2,
(val1, val2)
ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);
Example output (batchSize = 0):
INSERT INTO `tableName` (`col1`, `col2`) VALUES (val1, val2) ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);
INSERT INTO `tableName` (`col1`, `col2`) VALUES (val1, val2) ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);setBatchSize in class MySqlInsertWriterCopyright (c) 2006-2025 North Concepts Inc. All Rights Reserved.