To create a DDBulkLoad object, create an instance of the DDBulkLoadFactory class as shown in the following example.
import com.ddtek.jdbc.extensions.*
// Get Database Connection
Connection con = DriverManager.getConnection(
"jdbc:datadirect:redshift://server3:5439;
DatabaseName=Test;User=admin;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.
Suppose you need to migrate data from database system X to database Y. The following figure shows how your application would load the data from a ResultSet object created from a query. This scenario assumes that the driver is connected to both databases.
1. The application executes a query to the X 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 Y database.
3. The driver loads the data from the ResultSet object into the table.
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 a table on the X database.
1. The application creates a DDBulkLoad object.
2. The application specifies that the driver export the data from a table on database X into a CSV file.
3. The application instructs the driver to load data from the CSV file into the table on database Y table. The driver loads the data from the CSV file into the table on database Y.