org.apache.empire.db
Class DBSQLScript

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

public class DBSQLScript
extends ErrorObject
implements java.lang.Iterable<java.lang.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))


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.empire.commons.ErrorObject
ErrorObject.ObjectErrorInfo
 
Constructor Summary
DBSQLScript()
           
 
Method Summary
 boolean addStmt(java.lang.String sql)
          Adds a statement to the script.
 boolean addStmt(java.lang.StringBuilder sql)
          Adds a statement to the script.
The supplied StringBuilder will be reset to a length of 0
 void clear()
          Clears the script and delets all statements
 int getCount()
          Returns the number of statemetns in this script
 java.lang.String getStmt(int i)
          Returns the statement at the given index
 java.util.Iterator<java.lang.String> iterator()
          Returns an iterator
 boolean run(DBDatabaseDriver driver, java.sql.Connection conn, boolean ignoreErrors)
          Runs all SQL Statements using the supplied driver and connection.
 java.lang.String toString()
          Returns the sql script as a string
 
Methods inherited from class org.apache.empire.commons.ErrorObject
clearError, clearErrorInfo, error, error, error, error, error, error, error, getErrorInfo, getErrorMessage, getErrorParams, getErrorSource, getErrorType, getMessage, hasError, internalSetError, isExceptionsEnabled, setExceptionsEnabled, success
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DBSQLScript

public DBSQLScript()
Method Detail

addStmt

public boolean addStmt(java.lang.String sql)
Adds a statement to the script.

Parameters:
sql - the statement
Returns:
true if successful

addStmt

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

Parameters:
sql - the statement
Returns:
true if successful

getCount

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

Returns:
number of statements in this script

getStmt

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

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

clear

public void clear()
Clears the script and delets all statements


run

public boolean run(DBDatabaseDriver driver,
                   java.sql.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
Returns:
true if the script has been run successful or false otherwise

iterator

public java.util.Iterator<java.lang.String> iterator()
Returns an iterator

Specified by:
iterator in interface java.lang.Iterable<java.lang.String>

toString

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

Overrides:
toString in class java.lang.Object


Copyright © 2008-2009 Apache Software Foundation. All Rights Reserved.