Share via


SQLServerBulkCopyOptions Class

  • java.lang.Object
    • com.microsoft.sqlserver.jdbc.SQLServerBulkCopyOptions

Implements

java.io.Serializable

public class SQLServerBulkCopyOptions
implements java.io.Serializable

Provides a collection of settings that control how an instance of SQLServerBulkCopy behaves. Used when constructing a SQLServerBulkCopy instance to change how the writeToServer methods for that instance behave.

Constructor Summary

Constructor Description
SQLServerBulkCopyOptions()

Constructs a SQLServerBulkCopySettings class using defaults for all of the settings.

Method Summary

Modifier and Type Method and Description
int getBatchSize()

Returns the number of rows in each batch.

int getBulkCopyTimeout()

Returns the number of seconds for the operation to complete before it times out.

boolean isAllowEncryptedValueModifications()

Returns if allowEncryptedValueModifications option is enabled or not

boolean isCheckConstraints()

Returns whether constraints are to be checked while data is being inserted or not.

boolean isFireTriggers()

Returns if the server should fire insert triggers for rows being inserted into the database.

boolean isKeepIdentity()

Returns whether or not to preserve any source identity values.

boolean isKeepNulls()

Returns whether to preserve null values in the destination table regardless of the settings for default values, or if they should be replaced by default values (where applicable).

boolean isTableLock()

Returns whether SQLServerBulkCopy should obtain a bulk update lock for the duration of the bulk copy operation.

boolean isUseInternalTransaction()

Returns whether each batch of the bulk-copy operation will occur within a transaction or not.

void setAllowEncryptedValueModifications(boolean allowEncryptedValueModifications)

Sets whether the driver would send data as is or would decrypt the data and encrypt it again before sending to SQL Server

void setBatchSize(int batchSize)

Sets the number of rows in each batch.

void setBulkCopyTimeout(int timeout)

Sets the number of seconds for the operation to complete before it times out.

void setCheckConstraints(boolean checkConstraints)

Sets whether constraints are to be checked while data is being inserted or not.

void setFireTriggers(boolean fireTriggers)

Sets whether the server should be set to fire insert triggers for rows being inserted into the database.

void setKeepIdentity(boolean keepIdentity)

Sets whether or not to preserve any source identity values.

void setKeepNulls(boolean keepNulls)

Sets whether to preserve null values in the destination table regardless of the settings for default values, or if they should be replaced by default values (where applicable).

void setTableLock(boolean tableLock)

Sets whether SQLServerBulkCopy should obtain a bulk update lock for the duration of the bulk copy operation.

void setUseInternalTransaction(boolean useInternalTransaction)

Sets whether each batch of the bulk-copy operation will occur within a transaction or not.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

SQLServerBulkCopyOptions

public SQLServerBulkCopyOptions()

Constructs a SQLServerBulkCopySettings class using defaults for all of the settings.

Method Details

getBatchSize

public int getBatchSize()

Returns the number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.

Returns:

Number of rows in each batch.

getBulkCopyTimeout

public int getBulkCopyTimeout()

Returns the number of seconds for the operation to complete before it times out.

Returns:

Number of seconds before operation times out.

isAllowEncryptedValueModifications

public boolean isAllowEncryptedValueModifications()

Returns if allowEncryptedValueModifications option is enabled or not

Returns:

True if allowEncryptedValueModification is set to true; false otherwise.

isCheckConstraints

public boolean isCheckConstraints()

Returns whether constraints are to be checked while data is being inserted or not.

Returns:

True if constraints are to be checked; false otherwise.

isFireTriggers

public boolean isFireTriggers()

Returns if the server should fire insert triggers for rows being inserted into the database.

Returns:

True triggers are enabled; false otherwise.

isKeepIdentity

public boolean isKeepIdentity()

Returns whether or not to preserve any source identity values.

Returns:

True if source identity values are to be preserved; false if they are to be assigned by the destination.

isKeepNulls

public boolean isKeepNulls()

Returns whether to preserve null values in the destination table regardless of the settings for default values, or if they should be replaced by default values (where applicable).

Returns:

True if null values should be preserved; false if null values should be replaced by default values where applicable.

isTableLock

public boolean isTableLock()

Returns whether SQLServerBulkCopy should obtain a bulk update lock for the duration of the bulk copy operation.

Returns:

True to obtain row locks; false otherwise.

isUseInternalTransaction

public boolean isUseInternalTransaction()

Returns whether each batch of the bulk-copy operation will occur within a transaction or not.

Returns:

True if the batch will occur within a transaction; false otherwise.

setAllowEncryptedValueModifications

public void setAllowEncryptedValueModifications(boolean allowEncryptedValueModifications)

Sets whether the driver would send data as is or would decrypt the data and encrypt it again before sending to SQL Server

Use caution when specifying allowEncryptedValueModifications as this may lead to corrupting the database because the driver does not check if the data is indeed encrypted, or if it is correctly encrypted using the same encryption type, algorithm and key as the target column.

Parameters:

allowEncryptedValueModifications - enables bulk copying of encrypted data between tables or databases, without decrypting the data. Typically, an application would select data from encrypted columns from one table without decrypting the data (the app would connect to the database with the column encryption setting keyword set to disabled) and then would use this option to bulk insert the data, which is still encrypted.

setBatchSize

public void setBatchSize(int batchSize)

Sets the number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.

Parameters:

batchSize - Number of rows in each batch.

Throws:

SQLServerException - If the batchSize being set is invalid.

setBulkCopyTimeout

public void setBulkCopyTimeout(int timeout)

Sets the number of seconds for the operation to complete before it times out.

Parameters:

timeout - Number of seconds before operation times out.

Throws:

SQLServerException - If the timeout being set is invalid.

setCheckConstraints

public void setCheckConstraints(boolean checkConstraints)

Sets whether constraints are to be checked while data is being inserted or not.

Parameters:

checkConstraints - True if constraints are to be checked; false otherwise.

setFireTriggers

public void setFireTriggers(boolean fireTriggers)

Sets whether the server should be set to fire insert triggers for rows being inserted into the database.

Parameters:

fireTriggers - True triggers are to be enabled; false otherwise.

setKeepIdentity

public void setKeepIdentity(boolean keepIdentity)

Sets whether or not to preserve any source identity values.

Parameters:

keepIdentity - True if source identity values are to be preserved; false if they are to be assigned by the destination

setKeepNulls

public void setKeepNulls(boolean keepNulls)

Sets whether to preserve null values in the destination table regardless of the settings for default values, or if they should be replaced by default values (where applicable).

Parameters:

keepNulls - True if null values should be preserved; false if null values should be replaced by default values where applicable.

setTableLock

public void setTableLock(boolean tableLock)

Sets whether SQLServerBulkCopy should obtain a bulk update lock for the duration of the bulk copy operation.

Parameters:

tableLock - True to obtain row locks; false otherwise.

setUseInternalTransaction

public void setUseInternalTransaction(boolean useInternalTransaction)

Sets whether each batch of the bulk-copy operation will occur within a transaction or not.

Parameters:

useInternalTransaction - True if the batch will occur within a transaction; false otherwise.

Applies to