| |
|
| org.apache.tools.ant.taskdefs.JDBCTask org.apache.tools.ant.taskdefs.SQLExec
SQLExec | public class SQLExec extends JDBCTask (Code) | | 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.
since: Ant 1.2 |
Inner Class :public class Transaction | |
add | public void add(ResourceCollection rc)(Code) | | Adds a collection of resources (nested element).
Parameters: rc - a collection of resources containing SQL commands,each resource is run in a separate transaction. since: Ant 1.7 |
addFileset | public void addFileset(FileSet set)(Code) | | Adds a set of files (nested fileset attribute).
Parameters: set - a set of files contains SQL commands, each File is run ina separate transaction. |
addText | public void addText(String sql)(Code) | | Set an inline SQL command to execute.
NB: Properties are not expanded in this text unless
SQLExec.expandProperties is set.
Parameters: sql - an inline string containing the SQL command. |
createTransaction | public Transaction createTransaction()(Code) | | Add a SQL transaction to execute
a Transaction to be configured. |
getExpandProperties | public boolean getExpandProperties()(Code) | | is property expansion inside inline text enabled?
true if properties are to be expanded. since: Ant 1.7 |
printResults | protected void printResults(ResultSet rs, PrintStream out) throws SQLException(Code) | | print any results in the result set.
Parameters: rs - the resultset to print information about Parameters: out - the place to print results throws: SQLException - on SQL problems. since: Ant 1.6.3 |
setAppend | public void setAppend(boolean append)(Code) | | whether output should be appended to or overwrite
an existing file. Defaults to false.
since: Ant 1.5 Parameters: append - if true append to an existing file. |
setDelimiter | public void setDelimiter(String delimiter)(Code) | | 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.
Parameters: delimiter - the separator. |
setDelimiterType | public void setDelimiterType(DelimiterType delimiterType)(Code) | | 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.
Parameters: delimiterType - the type of delimiter - "normal" or "row". |
setEncoding | public void setEncoding(String encoding)(Code) | | Set the file encoding to use on the SQL files read in
Parameters: encoding - the encoding to use on the files |
setEscapeProcessing | public void setEscapeProcessing(boolean enable)(Code) | | Set escape processing for statements.
Parameters: enable - if true enable escape processing, default is true. since: Ant 1.6 |
setExpandProperties | public void setExpandProperties(boolean expandProperties)(Code) | | Enable property expansion inside nested text
Parameters: expandProperties - if true expand properties. since: Ant 1.7 |
setKeepformat | public void setKeepformat(boolean keepformat)(Code) | | whether or not format should be preserved.
Defaults to false.
Parameters: keepformat - The keepformat to set |
setOnerror | public void setOnerror(OnError action)(Code) | | Action to perform when statement fails: continue, stop, or abort
optional; default "abort"
Parameters: action - the action to perform on statement failure. |
setOutput | public void setOutput(File output)(Code) | | Set the output file;
optional, defaults to the Ant log.
Parameters: output - the output file to use for logging messages. |
setPrint | public void setPrint(boolean print)(Code) | | Print result sets from the statements;
optional, default false
Parameters: print - if true print result sets. |
setShowheaders | public void setShowheaders(boolean showheaders)(Code) | | Print headers for result sets from the
statements; optional, default true.
Parameters: showheaders - if true print headers of result sets. |
setShowtrailers | public void setShowtrailers(boolean showtrailers)(Code) | | Print trailing info (rows affected) for the SQL
Addresses Bug/Request #27446
Parameters: showtrailers - if true prints the SQL rows affected since: Ant 1.7 |
setSrc | public void setSrc(File srcFile)(Code) | | Set the name of the SQL file to be run.
Required unless statements are enclosed in the build file
Parameters: srcFile - the file containing the SQL command. |
|
|
|