Package com.illumon.iris.export.jdbc
Class JdbcLogger.Builder
java.lang.Object
com.illumon.iris.export.jdbc.JdbcLogger.Builder
- Enclosing class:
- JdbcLogger
A builder for constructing a JdbcLogger.
-
Constructor Summary
ConstructorsConstructorDescriptionInitialize a JdbcLogger builder with the given logger, JDBC connection, and target table information.Builder
(com.fishlib.io.logger.Logger logger, String jdbcDriver, String jdbcUrl, String schema, String tableName) Initialize a JdbcLogger builder with the given logger, JDBC connection, and target table information.Builder
(com.fishlib.io.logger.Logger logger, String jdbcDriver, String jdbcUrl, String catalog, String schema, String tableName) Initialize a JdbcLogger builder with the given logger, JDBC connection, and target table information. -
Method Summary
Modifier and TypeMethodDescriptionbatchSize
(int batchSize) Specify the batch size when writing to the JDBC data source.build()
Creates a JdbcLogger with configuration specified by arguments to the builder.Specify the Calendar to use when logging to JDBC date/datetime/timestamp columns.dataColumn
(String targetColumn) Add a data column for logging.dataColumn
(String targetColumn, String sourceColumn) Add a data column for logging.jdbcPassword
(String jdbcPassword) Specify the JDBC database password.Specify the JDBC database user.keyColumns
(String... keyColumns) Specify the set of columns that represent the primary key when logging to JDBC.logMode
(boolean logMode) Set log mode indicator.operationColumn
(String operationColumn) Specify the JDBC column that will receive the operation that resulted in that row.rowIndexColumn
(String rowIndexColumn) Specify the JDBC column that will receive the rowIndex of the source table row that resulted in a given JDBC row.
-
Constructor Details
-
Builder
public Builder(com.fishlib.io.logger.Logger logger, String jdbcDriver, String jdbcUrl, String catalog, String schema, String tableName) Initialize a JdbcLogger builder with the given logger, JDBC connection, and target table information.- Parameters:
logger
- logger to use when initializingjdbcDriver
- JDBC driver class namejdbcUrl
- JDBC connection URLcatalog
- JDBC database catalogschema
- JDBC database schematableName
- JDBC database table name
-
Builder
public Builder(com.fishlib.io.logger.Logger logger, String jdbcDriver, String jdbcUrl, String schema, String tableName) Initialize a JdbcLogger builder with the given logger, JDBC connection, and target table information. For connections that support multiple catalogs, the default catalog will be used.- Parameters:
logger
- logger to use when initializingjdbcDriver
- JDBC driver class namejdbcUrl
- JDBC connection URLschema
- JDBC database schematableName
- JDBC database table name
-
Builder
public Builder(com.fishlib.io.logger.Logger logger, String jdbcDriver, String jdbcUrl, String tableName) Initialize a JdbcLogger builder with the given logger, JDBC connection, and target table information. For connections that support multiple catalogs, the default catalog will be used. For connections with multiple schemas, the default schema will be used.- Parameters:
logger
- logger to use when initializingjdbcDriver
- JDBC driver class namejdbcUrl
- JDBC connection URLtableName
- JDBC database table name
-
-
Method Details
-
jdbcUser
Specify the JDBC database user. Only necessary if not specified as part of the JDBC URL.- Parameters:
jdbcUser
- JDBC database user name- Returns:
- this builder
-
jdbcPassword
Specify the JDBC database password. Only necessary if not specified as part of the JDBC URL.- Parameters:
jdbcPassword
- JDBC database password- Returns:
- this builder
-
calendar
Specify the Calendar to use when logging to JDBC date/datetime/timestamp columns. This can affect the way DateTime values are logged when the target column does not directly store an offset/timezone. SeePreparedStatement.setDate(int, Date, Calendar)
andPreparedStatement.setTimestamp(int, Timestamp, Calendar)
(int, Date, Calendar)} for details.- Parameters:
calendar
- Calendar to use for logging- Returns:
- this builder
-
batchSize
Specify the batch size when writing to the JDBC data source. For efficiency, the JDBC logger "batches" SQL statements when possible. Each Deephaven table update results in at least one commit, regardless of the batch size, so this represents a maximum. The default batch size is 500 rows. Batching is only effective when theTableLoggerBase.Flags
setting is not "RowByRow", since that effectively requires a commit for every row. When logging with updates, the "Atomic" setting is recommended, which requires only one commit for each Deephaven table update (which can affect any number of rows). When logging snapshots only, any setting other than "RowByRow" will take advantage of batching.- Parameters:
batchSize
- maximum batch size (legal range is 1 to 100,000)- Returns:
- this builder
-
logMode
Set log mode indicator. If not specified, this defaults to false. When in log mode, each update to the source Deephaven table will result in an INSERT into the target table (i.e. the target will be an append-only log of every update to the source). Otherwise, each operation is replicated in the target using the appropriate INSERT/UPDATE/DELETE operation, using the specified row key columns to uniquely identify rows.- Parameters:
logMode
- if true, run in log mode- Returns:
- this builder
-
rowIndexColumn
Specify the JDBC column that will receive the rowIndex of the source table row that resulted in a given JDBC row. APreparedStatement.setLong(int, long)
will be used to set this value, so the target column should be an SQL BIGINT or equivalent.- Parameters:
rowIndexColumn
- JDBC column that will receive the operation (must be compatible with 64 bit integer)- Returns:
- this builder
-
operationColumn
Specify the JDBC column that will receive the operation that resulted in that row. This is most useful in "log mode", in order to differentiate between Added/ModifiedOld/ModifiedNew/Removed operations in the source table. APreparedStatement.setString(int, java.lang.String)
will be used to set this value, so the target column should be a VARCHAR with length 11 or more.- Parameters:
operationColumn
- JDBC column that will receive the operation (must be compatible with a string value)- Returns:
- this builder
-
dataColumn
Add a data column for logging.- Parameters:
targetColumn
- column name, with the same name in the source and target.- Returns:
- this builder
-
dataColumn
Add a data column for logging.- Parameters:
targetColumn
- column name in the JDBC tablesourceColumn
- column name in the source Deephaven table- Returns:
- this builder
-
keyColumns
Specify the set of columns that represent the primary key when logging to JDBC. This set of column(s) will be used in order to generate the WHERE clause in UPDATE and DELETE operations, when not in "log mode". If in log mode, key columns are unnecessary, since every source table update will simply be logged as an INSERT to the JDBC target. The key columns should be either composed of a subset of the data columns (as they are named in the SQL table), or the rowIndex column. Each set of unique values in these columns should represent a unique row in order for logging to work properly. If present, a rowIndex column always provides this feature.- Parameters:
keyColumns
- an array of columns to use as the composite primary key- Returns:
- this builder
-
build
Creates a JdbcLogger with configuration specified by arguments to the builder.- Returns:
- a new JdbcLogger
- Throws:
SQLException
- if an error occurs while
-