public class DBSQLScript extends Object implements Iterable<String>
DBDatabaseDriver.getDDLScript(DBCmdType, DBObject, DBSQLScript)
)Modifier and Type | Class and Description |
---|---|
protected static class |
DBSQLScript.SQLStmt
SQLCmd
|
Modifier and Type | Field and Description |
---|---|
protected String |
commandSeparator |
protected ArrayList<DBSQLScript.SQLStmt> |
sqlStmtList |
Constructor and Description |
---|
DBSQLScript() |
DBSQLScript(String commandSeparator) |
Modifier and Type | Method and Description |
---|---|
void |
addDelete(DBCommand cmd,
DBTable table)
Adds an delete statement
|
void |
addInsert(DBCommand cmd)
Adds an insert statement
|
void |
addStmt(String sql)
Adds a statement to the script.
|
void |
addStmt(StringBuilder sql)
Adds a statement to the script.
The supplied StringBuilder will be reset to a length of 0 |
void |
addStmt(String sql,
Object[] params)
Adds a statement to the script.
|
void |
addUpdate(DBCommand cmd)
Adds an update statement
|
void |
clear()
Clears the script by removing all statements
|
int |
executeAll(DBDatabaseDriver driver,
Connection conn)
Executes all SQL Statements one by one using the supplied driver and connection.
|
int |
executeAll(DBDatabaseDriver driver,
Connection conn,
boolean ignoreErrors)
Executes all SQL Statements one by one using the supplied driver and connection.
|
int |
executeBatch(DBDatabaseDriver driver,
Connection conn)
Executes all SQL Statements as a JDBC Batch Job.
|
int |
getCount()
Returns the number of statements in this script
|
String |
getStmt(int i)
Returns the statement command at the given index
|
Object[] |
getStmtParams(int i)
Returns the statement command at the given index
|
void |
insertStmt(int i,
String stmt)
Inserts an entry in the list
|
void |
insertStmt(int i,
String stmt,
Object[] params)
Inserts an entry in the list
|
Iterator<String> |
iterator()
Returns an iterator
|
void |
removeStmt(int i)
Removes a statement from the list
|
void |
replaceStmt(int i,
String cmd)
Replaces an entry in the list
|
void |
replaceStmt(int i,
String cmd,
Object[] params)
Replaces an entry in the list
|
void |
run(DBDatabaseDriver driver,
Connection conn)
Deprecated.
|
int |
run(DBDatabaseDriver driver,
Connection conn,
boolean ignoreErrors)
Deprecated.
|
String |
toString()
Returns the sql script as a string
|
protected String commandSeparator
protected ArrayList<DBSQLScript.SQLStmt> sqlStmtList
public DBSQLScript()
public DBSQLScript(String commandSeparator)
public void addStmt(String sql)
sql
- the statementpublic void addStmt(String sql, Object[] params)
sql
- the statementparams
- the statement parameterspublic final void addStmt(StringBuilder sql)
sql
- the statementpublic void addInsert(DBCommand cmd)
cmd
- the insert commandpublic void addUpdate(DBCommand cmd)
cmd
- the insert commandpublic void addDelete(DBCommand cmd, DBTable table)
cmd
- the insert commandpublic int getCount()
public String getStmt(int i)
i
- index of the statement to retrievepublic Object[] getStmtParams(int i)
i
- index of the statement to retrievepublic void insertStmt(int i, String stmt, Object[] params)
i
- index of the statement to replacestmt
- the new statement for this index, or NULL to remove the statementpublic final void insertStmt(int i, String stmt)
i
- index of the statement to replacestmt
- the new statement for this index, or NULL to remove the statementpublic void replaceStmt(int i, String cmd, Object[] params)
i
- index of the statement to replacecmd
- the new statement for this index, or NULL to remove the statementparams
- the command params (optional)public final void replaceStmt(int i, String cmd)
i
- index of the statement to replacecmd
- the new statement for this index, or NULL to remove the statementpublic void removeStmt(int i)
i
- index of the statement to replacepublic void clear()
public int executeAll(DBDatabaseDriver driver, Connection conn, boolean ignoreErrors)
driver
- the driver used for statement executionconn
- the connectionignoreErrors
- true if errors should be ignoredpublic final int executeAll(DBDatabaseDriver driver, Connection conn)
driver
- the driver used for statement executionconn
- the connectionpublic int executeBatch(DBDatabaseDriver driver, Connection conn)
driver
- the driver used for statement executionconn
- the connectionignoreErrors
- true if errors should be ignored@Deprecated public final int run(DBDatabaseDriver driver, Connection conn, boolean ignoreErrors)
driver
- the driver used for statement executionconn
- the connectionignoreErrors
- true if errors should be ignored@Deprecated public final void run(DBDatabaseDriver driver, Connection conn)
driver
- the driver used for statement executionconn
- the connectionCopyright © 2008–2015 Apache Software Foundation. All rights reserved.