skip to main content
Getting Started : Advanced Features : Using DataDirect Bulk Load : Using a DDBulkLoad Object
  
Using a DDBulkLoad Object
To create a DDBulkLoad object, create an instance of the DDBulkLoadFactory class as shown in the following examples.
Example A: Creating a DDBulkLoad Object for an Oracle Connection
import com.ddtek.jdbc.extensions.*
// Get Database Connection
Connection con = DriverManager.getConnection(
   "jdbc:datadirect:oracle://server3:1521;ServiceName=ORCL;User=test;
   Password=secret");

// Get a DDBulkLoad object
DDBulkLoad bulkLoad = com.ddtek.jdbc.extensions.DDBulkLoadFactory.getInstance(con);
Example B: Creating a DDBulkLoad Object for a Salesforce Connection
import com.ddtek.jdbc.extensions.*
// Get Salesforce Connection
Connection con = DriverManager.getConnection(
   "jdbc:datadirect:sforce://login.salesforce.com;User=test@abccorp.com;
   Password=secret");

// Get a DDBulkLoad object
DDBulkLoad bulkLoad = com.ddtek.jdbc.extensions.DDBulkLoadFactory.getInstance(con);
Once your application has created a DDBulkLoad object, you can use the DDBulkLoad methods to provide the driver with the following instructions:
*The location where the driver obtains the data to load. The driver can obtain data from either of the following sources:
ResultSet object generated from a query.
Comma-separated value (CSV) file. The driver can export data from a table or ResultSet object into a CSV file, or the driver can use a CSV file created by another DataDirect Connect product.
*The location where the driver loads the data (table name, and optionally for the Salesforce driver, column names)
Example C: Loading Data Using a ResultSet Object
Suppose after upgrading from an Oracle 10g database to an Oracle 11g database, you need to migrate data from the old database to the new database. The following figure 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.
Image showing the migration of data from one serve to another via the bulk load process
1. The application executes a query to the Oracle 10g database in the normal way and retrieves the results in a ResultSet object.
2. The application creates a DDBulkLoad object and instructs the driver to load data from the ResultSet object into the Oracle 11g database.
3. The driver loads the data from the ResultSet object into the Oracle 11g table.
Example D: Loading Data Using a CSV File
Using the same scenario as described in Example C, the following figure 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 10g table.
Image showing the migration of data from one serve to another via the bulk load process
1. The application creates a DDBulkLoad object
2. The application specifies that the driver export the data from an Oracle 10g table into a CSV file.
3. The application instructs the driver to load data from the CSV file into the Oracle 11g table. The driver loads the data from the CSV file into the Oracle 11g table.
For instructions on exporting data to a CSV file, see Exporting Data to a CSV File.
For instructions on loading data, see Loading Data From a ResultSet Object and Loading Data From a CSV File.
See Permissions for Bulk Load from a CSV File for information about granting permissions for bulk loading from a CSV file.
Refer to "JDBC Extensions" in the DataDirect Connect Series for JDBC Reference for a description of the bulk load methods.
For details, see the following topics:
* Exporting Data to a CSV File
* Loading Data From a ResultSet Object
* Loading Data From a CSV File
* Specifying the Bulk Load Operation
* Logging