Purpose

Determines the mechanism that is used to execute batch inserts.

Valid Values

nativeBatch | copy

Behavior

If set to nativeBatch, the driver uses the PostgreSQL native batch protocol to insert all batched parameters.

If set to copy, the driver creates an in-memory representation of a CSV file based on all the rows contained in a parameter array, and the PostgreSQL COPY command is executed to insert the rows from the CSV file into the target table.

Notes

  • BatchMechanism determines the mechanism used to perform batch inserts only. For update and delete batch operations, the driver uses the native batch mechanism to handle the request.
  • When BatchMechanism=nativeBatch, individual update counts are returned for each statement or parameter set in the batch as required by the JDBC 3.0 specification.
  • When BatchMechanism=copy, substantial performance gains can be made. However, the following limitations apply.
    • Individual update counts are not returned. However, the total number of update counts are returned for each statement or parameter set in the batch.
    • All columns in the insert command should be bound with parameters. Mixed column binding statements (some columns bound as parameters while others are bound with literals) are not supported. Mixed column binding statements will result in the following error.
      [DataDirect][PostgreSQL JDBC Driver][PostgreSQL] missing data for column "column_name"
    • The entire batch insert is ATOMIC. If any issues are encountered, the entire operation fails and no rows are inserted.

Data Source Methods

public String getBatchMechanism()

public void setBatchMechanism(String)

Default

nativeBatch

Data Type

String

See also