Class JdbcLogger.Builder

java.lang.Object
com.illumon.iris.export.jdbc.JdbcLogger.Builder
Enclosing class:
JdbcLogger

public static class JdbcLogger.Builder extends Object
A builder for constructing a JdbcLogger.
  • 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 initializing
      jdbcDriver - JDBC driver class name
      jdbcUrl - JDBC connection URL
      catalog - JDBC database catalog
      schema - JDBC database schema
      tableName - 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 initializing
      jdbcDriver - JDBC driver class name
      jdbcUrl - JDBC connection URL
      schema - JDBC database schema
      tableName - 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 initializing
      jdbcDriver - JDBC driver class name
      jdbcUrl - JDBC connection URL
      tableName - JDBC database table name
  • Method Details

    • jdbcUser

      public JdbcLogger.Builder jdbcUser(String 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

      public JdbcLogger.Builder jdbcPassword(String 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

      public JdbcLogger.Builder calendar(Calendar 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. See PreparedStatement.setDate(int, Date, Calendar) and PreparedStatement.setTimestamp(int, Timestamp, Calendar) (int, Date, Calendar)} for details.
      Parameters:
      calendar - Calendar to use for logging
      Returns:
      this builder
    • batchSize

      public JdbcLogger.Builder batchSize(int 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 the TableLoggerBase.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

      public JdbcLogger.Builder logMode(boolean 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

      public JdbcLogger.Builder rowIndexColumn(String rowIndexColumn)
      Specify the JDBC column that will receive the rowIndex of the source table row that resulted in a given JDBC row. A PreparedStatement.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

      public JdbcLogger.Builder operationColumn(String 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. A PreparedStatement.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

      public JdbcLogger.Builder dataColumn(String targetColumn)
      Add a data column for logging.
      Parameters:
      targetColumn - column name, with the same name in the source and target.
      Returns:
      this builder
    • dataColumn

      public JdbcLogger.Builder dataColumn(String targetColumn, String sourceColumn)
      Add a data column for logging.
      Parameters:
      targetColumn - column name in the JDBC table
      sourceColumn - column name in the source Deephaven table
      Returns:
      this builder
    • keyColumns

      public JdbcLogger.Builder keyColumns(String... 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

      public JdbcLogger build() throws SQLException
      Creates a JdbcLogger with configuration specified by arguments to the builder.
      Returns:
      a new JdbcLogger
      Throws:
      SQLException - if an error occurs while