public class JdbcLogger extends Object implements TableLoggerBase, AutoCloseable
A utility that logs Deephaven table snapshots and/or incremental updates to a JDBC table. It is expected that the target table is "compatible" with the source: JDBC metadata is interrogated to ensure the types of the source table columns match those of the corresponding target columns. Column names may be mapped, but any additional conversion must be performed in Deephaven prior to logging.
This logger may be used in two "modes". The default reproduces the content of the source table via a combination of SQL INSERT, UPDATE and DELETE statements (batched when possible). In "log mode", each incremental update to the source table is logged as an INSERT to the target table, along with (optional) information about which row was affected and the relevant operation (Added/Removed/Modified).
In addition, a number of different transaction modes may be used:
Modifier and Type | Class and Description |
---|---|
static class |
JdbcLogger.Builder |
TableLoggerBase.Flags, TableLoggerBase.Handle, TableLoggerBase.Operation
DEFAULT_TABLELOGGER_FLAGS
Modifier and Type | Method and Description |
---|---|
static JdbcLogger.Builder |
builder(com.fishlib.io.logger.Logger logger,
String jdbcDriver,
String jdbcUrl,
String tableName) |
static JdbcLogger.Builder |
builder(com.fishlib.io.logger.Logger logger,
String jdbcDriver,
String jdbcUrl,
String schema,
String tableName) |
static JdbcLogger.Builder |
builder(com.fishlib.io.logger.Logger logger,
String jdbcDriver,
String jdbcUrl,
String catalog,
String schema,
String tableName) |
void |
close() |
TableLoggerBase.Handle |
getLogHandle(Table tableToLog,
Collection<String> keyColumns)
Gets a handle suitable for use with logTableHandle.
|
void |
logTable(Table tableToLog,
Index index,
TableLoggerBase.Flags flags,
boolean logUpdates,
boolean logPrevValues,
Collection<String> keyColumns)
Log the contents of the given table to the JDBC.
|
void |
stopLoggingUpdates()
If we are presently logging updates, stop and remove the listener from the source table.
|
public void close()
close
in interface AutoCloseable
public TableLoggerBase.Handle getLogHandle(Table tableToLog, Collection<String> keyColumns)
TableLoggerBase
getLogHandle
in interface TableLoggerBase
tableToLog
- the table to log, must conform to the definition used to create this loggerkeyColumns
- if not null, gives the columns for which to log previous values on remove and row modificationpublic void logTable(Table tableToLog, Index index, TableLoggerBase.Flags flags, boolean logUpdates, boolean logPrevValues, Collection<String> keyColumns)
logTable
in interface TableLoggerBase
tableToLog
- the table to log, must conform to the definition used to create this loggerindex
- the subset of the table to logflags
- controls the transaction behaviorlogUpdates
- if true, continue to log updates to the tablelogPrevValues
- if true, log the old version of each row when rows are modified (only applicable when logUpdates is true)keyColumns
- if specified, log only these columns when logging previous values. Make sure the target columns are nullablepublic void stopLoggingUpdates()
public static JdbcLogger.Builder builder(com.fishlib.io.logger.Logger logger, String jdbcDriver, String jdbcUrl, String catalog, String schema, String tableName)
public static JdbcLogger.Builder builder(com.fishlib.io.logger.Logger logger, String jdbcDriver, String jdbcUrl, String schema, String tableName)
public static JdbcLogger.Builder builder(com.fishlib.io.logger.Logger logger, String jdbcDriver, String jdbcUrl, String tableName)