Table 3-9 and
Table 3-10 describe the bulk load behavior for the drivers.
In addition, for the Salesforce driver, you can configure the driver to use the bulk load protocol when it encounters a request to execute a single Insert, Update, or Delete statement that affects multiple rows. See
“Using Bulk Load for Single Inserts/Updates/Deletes (Salesforce Driver)”.
Suppose after upgrading from an Oracle 10g database to an Oracle 11
g database, you need to migrate data from the old database to the new database.
Figure 3-3 shows how your application would load the data from a ResultSet object created from a query. This scenario assumes that the Oracle driver is connected to both databases.
Using the same scenario as described in Example C, Figure 3-4 shows how you would load the data using a CSV file instead of a ResultSet object. The CSV file is created by exporting data from an Oracle 10
g table.
See “Permissions for Bulk Load from a CSV File” for information about granting permissions for bulk loading from a CSV file.
Refer to Chapter 2 “JDBC Extensions” in the
DataDirect Connect Series for JDBC Reference for a description of the bulk load methods.
If the CSV file does not already exist, the driver creates it when the export() method is executed. The driver also creates a bulk load configuration file, which describes the structure of the CSV file. For more information about using CSV files, see
“Using CSV Files”. Refer to
Chapter 2 “JDBC Extensions” in the
DataDirect Connect Series for JDBC Reference for more information about bulk load methods.
Use the setTableName() method to specify the table to load the data. Then, use the load() method, specifying the ResultSet object. For example, to load data from a ResultSet object named rs into a table named GBMAXTABLE, you would specify:
Use the BulkLoadBatchSize property to specify the number of rows the driver loads at a time when bulk loading data. Performance can be improved by increasing the number of rows the driver loads at a time because fewer network round trips are required. Be aware that increasing the number of rows that are loaded also causes the driver to consume more memory on the client. Refer to
Chapter 2 “JDBC Extensions” in the
DataDirect Connect Series for JDBC Reference for more information about bulk load methods.
Use the setTableName() method to specify the table to load the data. Then, use the load() method, specifying the CSV file. For example, to load data from a file named tmp.csv into a table named GBMAXTABLE, you would specify:
For the Salesforce driver, you also can specify the columns to which you want to load the data. This example loads the first column in the CSV file to the ColName1 column, the second column in the CSV file to the ColName2 column, and the third column in the CSV file to the ColName3 column:
Use the BulkLoadBatchSize property to specify the number of rows the driver loads at a time when bulk loading data. Performance can be improved by increasing the number of rows the driver loads at a time because fewer network round trips are required. Be aware that increasing the number of rows that are loaded also causes the driver to consume more memory on the client. Refer to
Chapter 2 “JDBC Extensions” in the
DataDirect Connect Series for JDBC Reference for more information about bulk load methods.
If logging is enabled for bulk load, a log file records information for each bulk load operation. Logging is enabled by specifying a file name and location for the log file using the setLogFile() method.
NOTE: If coding a path on Windows to the log file in a Java string, the backslash character (\) must be preceded by the Java escape character, a backslash. For example:
C:\\temp\\bulk_load.log.
For all drivers, except the Salesforce driver, the driver uses the native bulk load protocol for database connections when the EnableBulkLoad property is set to
true. For example, if you set the EnableBulkLoad property to
true, the driver would use bulk load for the following batch insert request.
In some cases, the driver may not be able to use bulk load because of restrictions enforced by the bulk load protocol and will downgrade to a batch mechanism. For example, if the data being loaded has a data type that is not supported by the bulk load protocol, the driver cannot use bulk load, but will use the batch mechanism instead.
For the Salesforce driver, when the EnableBulkLoad property is set to true and the number of rows to be inserted in the batch is larger than BulkLoadThreshold, the driver uses the Salesforce Bulk API instead of the Web service API.
For all drivers, use the BulkLoadBatchSize property to specify the number of rows the driver loads at a time when bulk loading data. Performance can be improved by increasing the number of rows the driver loads at a time because fewer network round trips are required. Be aware that increasing the number of rows that are loaded also causes the driver to consume more memory on the client.
When the EnableBulkLoad property is set to true, the driver uses the Salesforce Bulk API for single Insert, Update, and Delete statements if the number of rows affected by the operation exceeds the threshold set by the BulkLoadThreshold connection property. For example, if you set the EnableBulkLoad property to
true and the BulkLoadThreshold property to 2000, executing the following statement would use the Bulk API if the number of rows returned by
SELECT rowid, sys_name FROM account is more than 2000 rows.