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.
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.
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.