Class SqlCommitter

All Implemented Interfaces:
BatchConsumer, Committer, Configurable<SqlCommitterConfig>, AutoCloseable

public class SqlCommitter extends AbstractBatchCommitter<SqlCommitterConfig>

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