SQL*Loader
SqlLoaderControlDataSet
(org.dbunit.dataset.sqlloader) builds a dataset from a directory of
Oracle SQL*Loader control (.ctl) files, importing data already prepared
for Oracle’s SQL*Loader tool without converting it to another dbUnit format
first. It is a CachedDataSet fed by
SqlLoaderControlProducer/
SqlLoaderControlParser,
and translates the literal string "null" in the underlying data files into
an actual null value.
Directory Layout
A control-files directory needs one .ctl file per table, matching the
table’s name, plus a table-order manifest listing which tables to import in
which order:
sqlloader/ tables.lst COUNTRY.ctl COUNTRY.csv
tables.lst — the ordered table names:
COUNTRYCOUNTRY.ctl — a standard SQL*Loader control file:
LOAD DATA
INFILE '.\COUNTRY.csv'
APPEND INTO TABLE COUNTRY
FIELDS TERMINATED BY ";" OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
(
ID INTEGER EXTERNAL,
NAME CHAR,
ISO_ABBR CHAR
)COUNTRY.csv — the data file the control file’s INFILE points at:
1;AFGHANISTAN;AF
2;ALBANIA;AL
3;ALGERIA;DZLoading It
File ctlDir = new File("src/test/resources/sqlloader");
File orderedTablesFile = new File("src/test/resources/sqlloader/tables.lst");
IDataSet dataSet = new SqlLoaderControlDataSet(ctlDir, orderedTablesFile);An overload also accepts the ordered table names directly as a List
instead of a manifest file.


