public class DBSQLScript extends Object implements DBContextAware, Iterable<String>
DBMSHandler#getDDLScript(DDLActionType, DBObject, DBSQLScript)
)Modifier and Type | Class and Description |
---|---|
protected static class |
DBSQLScript.SQLStmt
SQLCmd
|
Modifier and Type | Field and Description |
---|---|
protected String |
commandSeparator |
protected DBContext |
context |
protected ArrayList<DBSQLScript.SQLStmt> |
sqlStmtList |
Constructor and Description |
---|
DBSQLScript(DBContext context) |
DBSQLScript(DBContext context,
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(DBSQLBuilder sql)
Adds a statement to the script.
|
void |
addStmt(String sql)
Adds a statement to the script.
|
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()
Executes all SQL Statements one by one using the supplied dbms and connection.
|
int |
executeAll(boolean ignoreErrors)
Executes all SQL Statements one by one using the supplied dbms and connection.
|
int |
executeBatch()
Executes all SQL Statements as a JDBC Batch Job.
|
DBContext |
getContext()
Returns the current Context
|
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
|
String |
toString()
Returns the sql script as a string
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected String commandSeparator
protected ArrayList<DBSQLScript.SQLStmt> sqlStmtList
protected final DBContext context
public DBSQLScript(DBContext context)
public DBContext getContext()
getContext
in interface DBContextAware
public void addStmt(String sql)
sql
- the statementpublic void addStmt(String sql, Object[] params)
sql
- the statementparams
- the statement parameterspublic final void addStmt(DBSQLBuilder 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(boolean ignoreErrors)
ignoreErrors
- true if errors should be ignoredpublic final int executeAll()
public int executeBatch()
Copyright © 2008–2023 Apache Software Foundation. All rights reserved.