The first step in performing a bulk load operation using a DDBulkLoad object is to create a DDBulkLoad object. A DDBulkLoad must be created with the getInstance method using the DDBulkLoadFactory class as shown in the following example.
import com.ddtek.jdbc.extensions.*
// Get SQLServer Connection
Connection con = DriverManager.getConnection(
"jdbc:datadirect:sqlserver://MyServer:1433;User=User123;
Password=secret;DatabaseName=MyDB");
// Get a DDBulkLoad object
DDBulkLoad bulkLoad = DDBulkLoadFactory.getInstance(con);
Once the DDBulkLoad object has been created, DDBulkLoad methods can be used to instruct the driver to obtain data from one location and load it to another location. The driver can obtain data either from a ResultSet object or from a CSV file.
Migrating data using a ResultSet object
The following steps would need to be taken to migrate data from Oracle to SQL Server using a ResultSet object.
Important: This scenario assumes that you are using the DataDirect Oracle driver to query the Oracle database and the DataDirect SQL Server driver to insert data to the SQL Server database.
1. The application creates a DDBulkLoad object.
2. The application executes a standard query on the Oracle database, and the Oracle driver retrieves the results as a ResultSet object.
3. The application instructs the SQL Server driver to load the data from the ResultSet object into SQL Server. (See "Loading data from a ResultSet object".)
Migrating data using a CSV file
The following steps would need to be taken to migrate data from Oracle to SQL Server using a CSV file.
1. The application creates a DDBulkLoad object.
2. The application instructs the Oracle driver to export the data from the Oracle database into a CSV file. (See "Exporting data to a CSV file.")
3. The application instructs the SQL Server driver to load data from the CSV file into SQL Server. (See "Loading data from a CSV file.")