Package com.norconex.committer.sql
Class SqlCommitter
java.lang.Object
com.norconex.committer.core.AbstractCommitter<SqlCommitterConfig>
com.norconex.committer.core.batch.AbstractBatchCommitter<SqlCommitterConfig>
com.norconex.committer.sql.SqlCommitter
- All Implemented Interfaces:
BatchConsumer,Committer,Configurable<SqlCommitterConfig>,AutoCloseable
Commit documents to an SQL table. Document metadata fields are mapped to table columns.
Handling of missing table/fields
By default, this Committer will throw an exception when trying to insert values into non-existing database table or fields. It is recommended you make sure your database table exists and the document fields being sent to the committer match your database fields.
Alternatively, you can provide the necessary SQLs to create a new
table as well as new fields as needed using
SqlCommitterConfig.setCreateTableSQL(String) and
SqlCommitterConfig.setCreateFieldSQL(String)
respectively. Make sure to use the following placeholder variables
as needed in the provided SQL(s) table and field creation, respectively:
Table creation
- {tableName}
-
Your table name, to be replaced with the value supplied with
SqlCommitterConfig.setTableName(String). - {primaryKey}
-
Your table primary key field name, to be replaced with the value
supplied with
SqlCommitterConfig.setPrimaryKey(String).
Field creation
- {fieldName}
- A field name to be created if you provided an SQL for creating new fields.
- Author:
- Pascal Essiembre
-
Field Summary
Fields inherited from interface com.norconex.commons.lang.config.Configurable
PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected voidSubclasses can perform additional closing logic by overriding this method.protected voidCommits the supplied batch.booleaninthashCode()protected voidSubclasses can perform additional initialization by overriding this method.toString()Methods inherited from class com.norconex.committer.core.batch.AbstractBatchCommitter
consume, doClean, doClose, doDelete, doInit, doUpsert, getInitializedQueueMethods inherited from class com.norconex.committer.core.AbstractCommitter
accept, applyFieldMappings, clean, close, delete, fireDebug, fireDebug, fireError, fireError, fireInfo, fireInfo, getCommitterContext, init, upsert
-
Constructor Details
-
SqlCommitter
public SqlCommitter()
-
-
Method Details
-
initBatchCommitter
Description copied from class:AbstractBatchCommitterSubclasses can perform additional initialization by overriding this method. Default implementation does nothing. The committer context and committer queue will be already initialized when invokingAbstractCommitter.getCommitterContext()andAbstractBatchCommitter.getInitializedQueue(), respectively.- Overrides:
initBatchCommitterin classAbstractBatchCommitter<SqlCommitterConfig>- Throws:
CommitterException- error initializing
-
commitBatch
Description copied from class:AbstractBatchCommitterCommits the supplied batch.- Specified by:
commitBatchin classAbstractBatchCommitter<SqlCommitterConfig>- Parameters:
it- the batch to commit- Throws:
CommitterException- could not commit the batch
-
closeBatchCommitter
Description copied from class:AbstractBatchCommitterSubclasses can perform additional closing logic by overriding this method. Default implementation does nothing.- Overrides:
closeBatchCommitterin classAbstractBatchCommitter<SqlCommitterConfig>- Throws:
CommitterException- error closing committer
-
equals
- Overrides:
equalsin classAbstractBatchCommitter<SqlCommitterConfig>
-
canEqual
- Overrides:
canEqualin classAbstractBatchCommitter<SqlCommitterConfig>
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractBatchCommitter<SqlCommitterConfig>
-
toString
- Overrides:
toStringin classAbstractBatchCommitter<SqlCommitterConfig>
-
getConfiguration
-