Java type: org.apache.ddlutils.task.WriteDataToDatabaseCommand

Inserts the data defined by the data XML file(s) into the database. This requires the schema in the database to match the schema defined by the XML files specified at the enclosing task.
DdlUtils will honor the order imposed by the foreign keys. Ie. first all required entries are inserted, then the dependent ones. Obviously this requires that no circular references exist in the schema (DdlUtils currently does not check this). Also, the referenced entries must be present in the data, otherwise the task will fail. This behavior can be turned off via the ensureForeignKeyOrder attribute.
In order to define data for foreign key dependencies that use auto-incrementing primary keys, simply use some unique values for their columns. DdlUtils then will automatically use the real primary key values when inserting the data. Note though that not every database supports the retrieval of auto-increment values which is necessary for this to work.


usebatchmode : boolean

Specifies whether batch mode shall be used for inserting the data. In batch mode, insert statements for the same table are bundled together and executed as one statement. This can be a lot faster than single insert statements but is not supported by all JDBC drivers/databases. To achieve the highest performance, you should group the data in the XML file according to the tables. This is because a batch insert only works for one table at a time. Thus when the table changes in an entry in the XML file, the batch is committed and then a new one is started.
Per default batch mode is not used.

datafile : File

Specifies the name of the single XML file that contains the data to insert into the database.
Use either this or fileset sub elements.

batchsize : int

The maximum number of insert statements to combine in one batch. The number typically depends on the JDBC driver and the amount of available memory.
This value is only used if useBatchMode is true.
The default value is 1.

failonerror : boolean

Specifies whether the execution shall stop if an error has occurred during the task runs.
By default execution will be stopped when an error is encountered.

ensureforeignkeyorder : boolean

Specifies whether the foreign key order shall be honored when inserting data into the database. If not, DdlUtils will simply assume that the entry order is correct, i.e. that referenced rows come before referencing rows in the data XML. Note that execution will be slower when DdlUtils has to ensure the foreign-key order of the data. Thus if you know that the data is specified in foreign key order turn this off.
Per default foreign key order is honored.

useexplicitidentityvalues : boolean

Defines whether values for identity columns in the data XML shall be used instead of letting the database define the value. Unless ensureForeignKeyOrder is set to false, setting this to false (the default) does not affect foreign keys as DdlUtils will automatically update the values of the columns of foreign keys pointing to the inserted row with the database-created values.
Default is false

Nested elements

⇒ Ant's fileset type

©2005-2007 Apache Software Foundation