Class AbstractWriteToJDBC

All Implemented Interfaces:
ConnectionSettings, LogicalOperator
Direct Known Subclasses:
DeleteFromJDBC, UpdateInJDBC, WriteToJDBC

public abstract class AbstractWriteToJDBC extends JDBCOperator
Abstract implementation of a JDBC writer.
  • Field Details

    • input

      protected final RecordPort input
    • renameMapping

      protected Map<String,String> renameMapping
    • keyNames

      protected String[] keyNames
    • commitInterval

      protected int commitInterval
    • isolationLevel

      protected int isolationLevel
    • initializeTableSQL

      protected String initializeTableSQL
    • finalizeTableSQL

      protected String finalizeTableSQL
  • Constructor Details

    • AbstractWriteToJDBC

      public AbstractWriteToJDBC()
    • AbstractWriteToJDBC

      public AbstractWriteToJDBC(JDBCOperator other)
  • Method Details

    • getKeyNames

      public String[] getKeyNames()
      Retrieves the field names (JDBC column names) to use as keys.
      Returns:
      the field names to use as keys
    • setKeyNames

      public void setKeyNames(String[] keyNames)
      Sets the field names (JDBC column names) to use as keys. Used when #outputMode is OutputMode#UPDATE or OutputMode#DELETE.
      Parameters:
      keyNames - the list of key name fields
    • getIsolationLevel

      public int getIsolationLevel()
      Retrieves the isolation level to use for the transactions.
      Returns:
      the isolation level to use for the transactions
    • setIsolationLevel

      public void setIsolationLevel(int level)
      Sets the isolation level to use for the transactions. See Connection.setTransactionIsolation(int) for isolation level explanations.
      Parameters:
      level - the isolation level to use for the transactions
    • getCommitInterval

      public int getCommitInterval()
      Retrieves the commit interval used by the JDBC driver.
      Returns:
      the commit interval used by the JDBC driver
    • setCommitInterval

      public void setCommitInterval(int commitInterval)
      Sets the commit interval used by the JDBC driver. This is the number of operations to execute between commit points.
      Parameters:
      commitInterval - number of operations executed between commits
    • getInitializeTableSQL

      public String getInitializeTableSQL()
      Retrieves the SQL statement to execute before processing any records.
      Returns:
      the SQL statement to execute before processing any records
    • setInitializeTableSQL

      public void setInitializeTableSQL(String initializeTableSQL)
      Sets the SQL statement to execute before processing any records. The most common use is initializing the table with a CREATE TABLE statement.

      This statement is executed only once, regardless of #partitionCount.

      Parameters:
      initializeTableSQL - the SQL statement to execute before processing any records
    • getFinalizeTableSQL

      public String getFinalizeTableSQL()
      Retrieves the SQL statement to execute after processing all the records.
      Returns:
      the SQL statement to execute after processing all the records
    • setFinalizeTableSQL

      public void setFinalizeTableSQL(String finalizeTableSQL)
      Sets the SQL statement to execute after processing all the records. One example use is a CREATE INDEX statement.

      This statement is executed only once, regardless of #partitionCount.

      Parameters:
      finalizeTableSQL - the SQL statement to execute after processing all the records
    • getRenameMapping

      public Map<String,String> getRenameMapping()
      Returns the rename mapping.
      Returns:
      the rename mapping.
    • setRenameMapping

      public void setRenameMapping(Map<String,String> renameMapping)
      Sets a rename mapping. This should be an ordered (i.e. LinkedHashMap) mapping of names. The keys in the map represent the original names in the record port. The values in the map represent column names in the table. Any columns that are not included in the mapping will be dropped.
      Parameters:
      renameMapping - the mapping from old to new names.
    • getInput

      public RecordPort getInput()
      Returns the input port.
      Returns:
      the input port
    • buildInsertStatement

      protected static String buildInsertStatement(String tableName, List<String> fields)
    • buildUpdateStatement

      protected static String buildUpdateStatement(String tableName, List<String> nonKeyFields, List<String> keyFields)
    • buildDeleteStatement

      protected static String buildDeleteStatement(String tableName, List<String> keyFields)
    • appendDelimited

      protected static void appendDelimited(StringBuilder command, String delimiter, List<String> fields, String fieldSuffix)
    • createTruncateTableSQL

      protected String createTruncateTableSQL()
    • createDropTableSQL

      protected String createDropTableSQL()
    • guessTableName

      protected String guessTableName()
    • getKeyNameList

      protected List<String> getKeyNameList(List<String> fieldNameList)