<database : sql>

Description

Executes a series of SQL statements on a database using JDBC.

Statements can either be read in from a text file using the src attribute or from between the enclosing SQL tags.

Multiple statements can be provided, separated by semicolons (or the defined delimiter). Individual lines within the statements can be commented using either --, // or REM at the start of the line.

The autocommit attribute specifies whether auto-commit should be turned on or off whilst executing the statements. If auto-commit is turned on each statement will be executed and committed. If it is turned off the statements will all be executed as one transaction.

The onerror attribute specifies how to proceed when an error occurs during the execution of one of the statements. The possible values are: continue execution, only show the error; stop execution and commit transaction; and abort execution and transaction and fail task.

Parameters

Attribute Description Type Required?
onerror Action to perform when statement fails: continue, stop, or abort optional; default "abort" String ["continue", "stop", "abort"] ?
userid String ?
password String ?
autocommit boolean ?
rdbms String ?
print Print result sets from the statements; optional, default false boolean ?
classpathref Reference ?
encoding Set the file encoding to use on the SQL files read in String ?
version String ?
url String ?
src Set the name of the SQL file to be run. Required unless statements are enclosed in the build file File ?
output Set the output file; optional, defaults to the Ant log. File ?
driver String ?
showheaders Print headers for result sets from the statements; optional, default true. boolean ?
classpath Path ?
delimitertype Set the delimiter type: "normal" or "row" (default "normal").

The delimiter type takes two values - normal and row. Normal means that any occurrence of the delimiter terminate the SQL command whereas with row, only a line containing just the delimiter is recognized as the end of the command.

String ["normal", "row"] ?
escapeprocessing Set escape processing for statements. boolean ?
append whether output should be appended to or overwrite an existing file. Defaults to false. boolean ?
caching boolean ?
keepformat whether or not format should be preserved. Defaults to false. boolean ?
delimiter Set the delimiter that separates SQL statements. Defaults to ";"; optional

For example, set this to "go" and delimitertype to "ROW" for Sybase ASE or MS SQL Server.

String ?

Parameters accepted as nested elements

This Task accepts text in its element body.

<fileset> ...

Moved out of MatchingTask to make it a standalone object that could be referenced (by scripts for example).
Attribute Description Type Required
refid Reference ?
file File ?
dir File ?
defaultexcludes boolean ?
followsymlinks boolean ?
casesensitive boolean ?
excludes String ?
includesfile File ?
excludesfile File ?
includes String ?

<classpath> ...

This object represents a path as used by CLASSPATH or PATH environment variable.

<sometask>
  <somepath>
    <pathelement location="/path/to/file.jar" />
    <pathelement path="/path/to/file2.jar:/path/to/class2;/path/to/class3" />
    <pathelement location="/path/to/file3.jar" />
    <pathelement location="/path/to/file4.jar" />
  </somepath>
</sometask>

The object implemention sometask must provide a method called createSomepath which returns an instance of Path. Nested path definitions are handled by the Path object and must be labeled pathelement.

The path element takes a parameter path which will be parsed and split into single elements. It will usually be used to define a path from an environment variable.

Attribute Description Type Required
refid Makes this instance in effect a reference to another Path instance.

You must not set another attribute or nest elements inside this element if you make it a reference.

Reference ?
path Parses a path definition and creates single PathElements. String ?

<transaction>

Contains the definition of a new transaction element. Transactions allow several files or blocks of statements to be executed using the same JDBC connection and commit operation in between.
Attribute Description Type Required
src File ?