Class PostgreSQLDatabaseAdapter

java.lang.Object
org.apache.nifi.processors.standard.db.impl.GenericDatabaseAdapter
org.apache.nifi.processors.standard.db.impl.PostgreSQLDatabaseAdapter
All Implemented Interfaces:
DatabaseAdapter

public class PostgreSQLDatabaseAdapter extends GenericDatabaseAdapter
  • Constructor Details

    • PostgreSQLDatabaseAdapter

      public PostgreSQLDatabaseAdapter()
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface DatabaseAdapter
      Overrides:
      getName in class GenericDatabaseAdapter
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface DatabaseAdapter
      Overrides:
      getDescription in class GenericDatabaseAdapter
    • supportsUpsert

      public boolean supportsUpsert()
      Description copied from interface: DatabaseAdapter
      Tells whether this adapter supports UPSERT.
      Returns:
      true if UPSERT is supported, false otherwise
    • supportsInsertIgnore

      public boolean supportsInsertIgnore()
      Description copied from interface: DatabaseAdapter
      Tells whether this adapter supports INSERT_IGNORE.
      Returns:
      true if INSERT_IGNORE is supported, false otherwise
    • getUpsertStatement

      public String getUpsertStatement(String table, List<String> columnNames, Collection<String> uniqueKeyColumnNames)
      Description copied from interface: DatabaseAdapter
      Returns an SQL UPSERT statement - i.e. UPDATE record or INSERT if id doesn't exist.

      There is no standard way of doing this so not all adapters support it - use together with DatabaseAdapter.supportsUpsert()!
      Parameters:
      table - The name of the table in which to update/insert a record into.
      columnNames - The name of the columns in the table to add values to.
      uniqueKeyColumnNames - The name of the columns that form a unique key.
      Returns:
      A String containing the parameterized jdbc SQL statement. The order and number of parameters are the same as that of the provided column list.
    • getInsertIgnoreStatement

      public String getInsertIgnoreStatement(String table, List<String> columnNames, Collection<String> uniqueKeyColumnNames)
      Description copied from interface: DatabaseAdapter
      Returns an SQL INSERT_IGNORE statement - i.e. Ignore record or INSERT if id doesn't exist.

      There is no standard way of doing this so not all adapters support it - use together with DatabaseAdapter.supportsInsertIgnore()!
      Parameters:
      table - The name of the table in which to ignore/insert a record into.
      columnNames - The name of the columns in the table to add values to.
      uniqueKeyColumnNames - The name of the columns that form a unique key.
      Returns:
      A String containing the parameterized jdbc SQL statement. The order and number of parameters are the same as that of the provided column list.
    • supportsCreateTableIfNotExists

      public boolean supportsCreateTableIfNotExists()
    • getAlterTableStatement

      public String getAlterTableStatement(String tableName, List<ColumnDescription> columnsToAdd)
    • getAutoCommitForReads

      public Optional<Boolean> getAutoCommitForReads(Integer fetchSize)
      Get the auto commit mode to use for reading from this database type. For PostgreSQL databases, auto commit mode must be set to false to cause a fetchSize other than 0 to take effect. More Details of this behaviour in PostgreSQL driver can be found in https://jdbc.postgresql.org//documentation/head/query.html.") For PostgreSQL, if autocommit is TRUE, then fetch size is treated as 0 which loads all rows of the result set to memory at once.
      Parameters:
      fetchSize - The number of rows to retrieve at a time. Value of 0 means retrieve all rows at once.
      Returns:
      Optional.empty() if auto commit mode does not matter and can be left as is. Return true or false to indicate whether auto commit needs to be true or false for this database.
    • getSQLForDataType

      public String getSQLForDataType(int sqlType)