org.apache.empire.db
Class DBSQLScript

java.lang.Object
  extended by org.apache.empire.db.DBSQLScript
All Implemented Interfaces:
Iterable<String>

public class DBSQLScript
extends Object
implements Iterable<String>

DBSQLScript
This class is a collection of sql command strings.
The class is used for obtaining and executing DDL commands supplied by the database driver (@see DBDatabaseDriver.getDDLScript(DBCmdType, DBObject, DBSQLScript))


Field Summary
protected  String commandSeparator
           
protected  ArrayList<String> sqlCmdList
           
 
Constructor Summary
DBSQLScript()
           
DBSQLScript(String commandSeparator)
           
 
Method Summary
 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 clear()
          Clears the script by removing all statements
 int getCount()
          Returns the number of statements in this script
 String getStmt(int i)
          Returns the statement at the given index
 void insertStmt(int i, String stmt)
          Inserts an entry in the list
 Iterator<String> iterator()
          Returns an iterator
 void run(DBDatabaseDriver driver, Connection conn)
          Runs all SQL Statements using the supplied driver and connection.
 void run(DBDatabaseDriver driver, Connection conn, boolean ignoreErrors)
          Runs all SQL Statements using the supplied driver and connection.
 void setStmt(int i, String stmt)
          Replaces an entry in the list
 String toString()
          Returns the sql script as a string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

commandSeparator

protected String commandSeparator

sqlCmdList

protected ArrayList<String> sqlCmdList
Constructor Detail

DBSQLScript

public DBSQLScript()

DBSQLScript

public DBSQLScript(String commandSeparator)
Method Detail

addStmt

public void addStmt(String sql)
Adds a statement to the script.

Parameters:
sql - the statement

addStmt

public final void addStmt(StringBuilder sql)
Adds a statement to the script.
The supplied StringBuilder will be reset to a length of 0

Parameters:
sql - the statement

getCount

public int getCount()
Returns the number of statements in this script

Returns:
number of statements in this script

getStmt

public String getStmt(int i)
Returns the statement at the given index

Parameters:
i - index of the statement to retrieve
Returns:
the sql statement

setStmt

public void setStmt(int i,
                    String stmt)
Replaces an entry in the list

Parameters:
i - index of the statement to replace
stmt - the new statement for this index, or NULL to remove the statement

insertStmt

public void insertStmt(int i,
                       String stmt)
Inserts an entry in the list

Parameters:
i - index of the statement to replace
stmt - the new statement for this index, or NULL to remove the statement

clear

public void clear()
Clears the script by removing all statements


run

public void run(DBDatabaseDriver driver,
                Connection conn,
                boolean ignoreErrors)
Runs all SQL Statements using the supplied driver and connection.

Parameters:
driver - the driver used for statement execution
conn - the connection
ignoreErrors - true if errors should be ignored

run

public void run(DBDatabaseDriver driver,
                Connection conn)
Runs all SQL Statements using the supplied driver and connection.

Parameters:
driver - the driver used for statement execution
conn - the connection

iterator

public Iterator<String> iterator()
Returns an iterator

Specified by:
iterator in interface Iterable<String>

toString

public String toString()
Returns the sql script as a string

Overrides:
toString in class Object


Copyright © 2008–2014 Apache Software Foundation. All rights reserved.