Loading Data from a CSV File
- Last Updated: June 13, 2020
- 1 minute read
- DataDirect Connectors
- JDBC
- Salesforce 6.0
- Documentation
The setTableName method should be used to specify the
table into which you want to load the data. Then, the load method is
used to specify the CSV file that contains the data you are loading. For example:
bulkLoad.setTableName("GBMAXTABLE");
bulkLoad.load("tmp.csv");
Alternatively, you can create a file reference to the CSV file, and use the load() method to specify the file reference:
File csvFile = new File("tmp.csv");
bulkLoad.load(csvFile);
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:
bulkLoad.setTableName("GBMAXTABLE(ColName1, ColName2, ColName3)");
bulkLoad.load("tmp.csv");
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. See "JDBC Extensions" for more information about bulk load methods.