|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tools.ant.ProjectComponent org.apache.tools.ant.Task org.apache.torque.task.TorqueSQLExec
public class TorqueSQLExec
This task uses an SQL -> Database map in the form of a properties file to insert each SQL file listed into its designated database.
Nested Class Summary | |
---|---|
static class |
TorqueSQLExec.DelimiterType
|
static class |
TorqueSQLExec.OnError
Enumerated attribute with the values "continue", "stop" and "abort" for the onerror attribute. |
class |
TorqueSQLExec.Transaction
Contains the definition of a new transaction element. |
Field Summary | |
---|---|
private boolean |
autocommit
Autocommit flag. |
private org.apache.tools.ant.types.Path |
classpath
|
private Connection |
conn
Database connection |
private String |
delimiter
SQL Statement delimiter |
private String |
delimiterType
The delimiter type indicating whether the delimiter will only be recognized on a line by itself |
private String |
driver
DB driver. |
private String |
encoding
Encoding to use when reading SQL statements from a file |
private int |
goodSql
|
private org.apache.tools.ant.AntClassLoader |
loader
|
private String |
onError
Action to perform if an error is found |
private File |
output
Results Output file. |
private String |
password
Password |
private boolean |
print
Print SQL results. |
private String |
rdbms
RDBMS Product needed for this SQL. |
private boolean |
showheaders
Print header columns. |
private File |
sqldbmap
Properties file that maps an individual SQL file to a database. |
private String |
srcDir
Src directory for the files listed in the sqldbmap. |
private Statement |
statement
SQL statement |
private int |
totalSql
|
private String |
url
DB url. |
private String |
userId
User name. |
private String |
version
RDBMS Version needed for this SQL. |
Fields inherited from class org.apache.tools.ant.Task |
---|
description, location, target, taskName, taskType, wrapper |
Fields inherited from class org.apache.tools.ant.ProjectComponent |
---|
project |
Constructor Summary | |
---|---|
TorqueSQLExec()
|
Method Summary | |
---|---|
void |
addText(String sql)
Deprecated. This method has no effect and will be removed in a future version. |
org.apache.tools.ant.types.Path |
createClasspath()
Create the classpath for loading the driver. |
protected void |
execSQL(String sql,
PrintStream out)
Exec the sql statement. |
void |
execute()
Load the sql file and then execute it |
File |
getSqlDbMap()
Get the sqldbmap properties file. |
String |
getSrcDir()
Get the src directory for the sql files listed in the sqldbmap file. |
private void |
insertDatabaseSqlFiles(String url,
String database,
List<?> transactions)
Take the base url, the target database and insert a set of SQL files into the target database. |
protected boolean |
isValidRdbms(Connection conn)
Verify if connected to the correct RDBMS |
protected void |
printResults(PrintStream out)
print any results in the statement. |
protected void |
runStatements(Reader reader,
PrintStream out)
Read the statements from the .sql file and execute them. |
void |
setAutocommit(boolean autocommit)
Set the autocommit flag for the DB connection. |
void |
setClasspath(org.apache.tools.ant.types.Path classpath)
Set the classpath for loading the driver. |
void |
setClasspathRef(org.apache.tools.ant.types.Reference r)
Set the classpath for loading the driver using the classpath reference. |
void |
setDelimiter(String delimiter)
Set the statement delimiter. |
void |
setDelimiterType(TorqueSQLExec.DelimiterType delimiterType)
Set the Delimiter type for this sql task. |
void |
setDriver(String driver)
Set the JDBC driver to be used. |
void |
setEncoding(String encoding)
Set the file encoding to use on the sql files read in |
void |
setOnerror(TorqueSQLExec.OnError action)
Set the action to perform onerror |
void |
setOutput(File output)
Set the output file. |
void |
setPassword(String password)
Set the password for the DB connection. |
void |
setPrint(boolean print)
Set the print flag. |
void |
setRdbms(String vendor)
Set the rdbms required |
void |
setShowheaders(boolean showheaders)
Set the showheaders flag. |
void |
setSqlDbMap(String sqldbmap)
Set the sqldbmap properties file. |
void |
setSrcDir(String srcDir)
Set the src directory for the sql files listed in the sqldbmap file. |
void |
setUrl(String url)
Set the DB connection url. |
void |
setUserid(String userId)
Set the user name for the DB connection. |
void |
setVersion(String version)
Set the version required |
Methods inherited from class org.apache.tools.ant.Task |
---|
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType |
Methods inherited from class org.apache.tools.ant.ProjectComponent |
---|
getProject, setProject |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int goodSql
private int totalSql
private org.apache.tools.ant.types.Path classpath
private org.apache.tools.ant.AntClassLoader loader
private Connection conn
private boolean autocommit
private Statement statement
private String driver
private String url
private String userId
private String password
private String delimiter
private String delimiterType
private boolean print
private boolean showheaders
private File output
private String rdbms
private String version
private String onError
private String encoding
private String srcDir
private File sqldbmap
Constructor Detail |
---|
public TorqueSQLExec()
Method Detail |
---|
public void setSqlDbMap(String sqldbmap)
sqldbmap
- filename for the sqldbmappublic File getSqlDbMap()
public void setSrcDir(String srcDir)
srcDir
- sql source directorypublic String getSrcDir()
public void setClasspath(org.apache.tools.ant.types.Path classpath)
classpath
- the classpathpublic org.apache.tools.ant.types.Path createClasspath()
public void setClasspathRef(org.apache.tools.ant.types.Reference r)
r
- reference to the classpathpublic void addText(String sql)
sql
- sql command to executepublic void setDriver(String driver)
driver
- driver class namepublic void setUrl(String url)
url
- connection urlpublic void setUserid(String userId)
userId
- database userpublic void setEncoding(String encoding)
encoding
- the encoding to use on the filespublic void setPassword(String password)
password
- database passwordpublic void setAutocommit(boolean autocommit)
autocommit
- the autocommit flagpublic void setDelimiter(String delimiter)
For example, set this to "go" and delimitertype to "ROW" for Sybase ASE or MS SQL Server.
delimiter
- public void setDelimiterType(TorqueSQLExec.DelimiterType delimiterType)
delimiterType
- public void setPrint(boolean print)
print
- public void setShowheaders(boolean showheaders)
showheaders
- public void setOutput(File output)
output
- public void setRdbms(String vendor)
vendor
- public void setVersion(String version)
version
- public void setOnerror(TorqueSQLExec.OnError action)
action
- public void execute() throws org.apache.tools.ant.BuildException
execute
in class org.apache.tools.ant.Task
org.apache.tools.ant.BuildException
private void insertDatabaseSqlFiles(String url, String database, List<?> transactions)
url
- database
- transactions
- protected void runStatements(Reader reader, PrintStream out) throws SQLException, IOException
reader
- out
-
SQLException
IOException
protected boolean isValidRdbms(Connection conn)
conn
- protected void execSQL(String sql, PrintStream out) throws SQLException
sql
- out
-
SQLException
protected void printResults(PrintStream out) throws SQLException
out
-
SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |