org.kuali.db
Class SQLExecutor

java.lang.Object
  extended by org.kuali.db.SQLExecutor

public class SQLExecutor
extends Object

Executes SQL statements


Field Summary
static String ON_ERROR_ABORT
          Call setOnError(String) with this value to abort SQL command execution if an error is found.
static String ON_ERROR_ABORT_AFTER
          Call setOnError(String) with this value to continue SQL command execution until all commands have been attempted, then abort the build if an SQL error occurred in any of the commands.
static String ON_ERROR_CONTINUE
          Call setOnError(String) with this value to continue SQL command execution if an error is found.
 
Constructor Summary
SQLExecutor()
           
 
Method Summary
 void addListener(DatabaseListener listener)
           
 void debug(String message)
           
 void error(String message)
           
 void error(Throwable throwable, String message)
           
protected  void execSQL(String sql, PrintStream out)
          Exec the sql statement.
 void execute()
           
 void executeSql(String sql)
           
 void executeTransaction(Transaction transaction)
           
protected  void fireAfterExecuteSQL(int totalStatements, String sql)
           
protected  void fireAfterProcessingSQLResults(int totalStatements, int successfulStatements, int updateCountTotal, String sql)
           
protected  void fireBeforeExecuteSQL(int totalStatements, String sql)
           
protected  void fireBeginTransaction(Transaction transaction)
           
protected  void fireFinishTransaction(Transaction transaction)
           
protected  void fireMessageLogged(String message)
           
protected  void fireMessageLogged(String message, MessagePriority priority)
           
 Connection getConn()
           
 String getDelimiter()
           
 String getDelimiterType()
           
protected  DatabaseEvent getExecuteSQLEvent(int totalStatements, String sql)
           
 List<DatabaseListener> getListeners()
           
 String getOnError()
           
 String getOutputDelimiter()
           
 Statement getStatement()
           
 int getSuccessfulStatements()
           
 int getTotalStatements()
           
 Vector<Transaction> getTransactions()
           
 void info(String message)
           
 boolean isAppend()
           
 boolean isAutocommit()
           
 boolean isConnectionError()
           
 boolean isEscapeProcessing()
           
 boolean isKeepFormat()
           
 boolean isPrintResultSet()
           
 boolean isShowheaders()
           
 boolean isSkipOnConnectionError()
           
protected  void printResultSet(ResultSet rs, PrintStream out)
          print any results in the result set.
protected  void runStatements(Reader reader, PrintStream out)
          read in lines and execute them
protected  void runTransaction(Transaction t, PrintStream out)
           
 void setAppend(boolean append)
           
 void setAutocommit(boolean autocommit)
           
 void setConn(Connection conn)
           
 void setConnectionError(boolean connectionError)
           
 void setDelimiter(String delimiter)
           
 void setDelimiterType(String delimiterType)
           
 void setEscapeProcessing(boolean escapeProcessing)
           
 void setKeepFormat(boolean keepFormat)
           
 void setListeners(List<DatabaseListener> listeners)
           
 void setOnError(String onError)
           
 void setOutputDelimiter(String outputDelimiter)
           
 void setPrintResultSet(boolean printResultSet)
           
 void setShowheaders(boolean showheaders)
           
 void setSkipOnConnectionError(boolean skipOnConnectionError)
           
 void setStatement(Statement statement)
           
 void setSuccessfulStatements(int successfulStatements)
           
 void setTotalStatements(int totalStatements)
           
 void setTransactions(Vector<Transaction> transactions)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ON_ERROR_ABORT

public static final String ON_ERROR_ABORT
Call setOnError(String) with this value to abort SQL command execution if an error is found.

See Also:
Constant Field Values

ON_ERROR_ABORT_AFTER

public static final String ON_ERROR_ABORT_AFTER
Call setOnError(String) with this value to continue SQL command execution until all commands have been attempted, then abort the build if an SQL error occurred in any of the commands.

See Also:
Constant Field Values

ON_ERROR_CONTINUE

public static final String ON_ERROR_CONTINUE
Call setOnError(String) with this value to continue SQL command execution if an error is found.

See Also:
Constant Field Values
Constructor Detail

SQLExecutor

public SQLExecutor()
Method Detail

addListener

public void addListener(DatabaseListener listener)

fireMessageLogged

protected void fireMessageLogged(String message)

fireMessageLogged

protected void fireMessageLogged(String message,
                                 MessagePriority priority)

fireBeginTransaction

protected void fireBeginTransaction(Transaction transaction)

fireFinishTransaction

protected void fireFinishTransaction(Transaction transaction)

getExecuteSQLEvent

protected DatabaseEvent getExecuteSQLEvent(int totalStatements,
                                           String sql)

fireBeforeExecuteSQL

protected void fireBeforeExecuteSQL(int totalStatements,
                                    String sql)

fireAfterExecuteSQL

protected void fireAfterExecuteSQL(int totalStatements,
                                   String sql)

fireAfterProcessingSQLResults

protected void fireAfterProcessingSQLResults(int totalStatements,
                                             int successfulStatements,
                                             int updateCountTotal,
                                             String sql)

info

public void info(String message)

debug

public void debug(String message)

error

public void error(Throwable throwable,
                  String message)

error

public void error(String message)

executeSql

public void executeSql(String sql)
                throws SQLException
Throws:
SQLException

executeTransaction

public void executeTransaction(Transaction transaction)
                        throws SQLException
Throws:
SQLException

execute

public void execute()
             throws SQLException
Throws:
SQLException

runTransaction

protected void runTransaction(Transaction t,
                              PrintStream out)
                       throws IOException,
                              SQLException
Throws:
IOException
SQLException

execSQL

protected void execSQL(String sql,
                       PrintStream out)
                throws SQLException
Exec the sql statement.

Parameters:
sql - query to execute
out - the outputstream
Throws:
SQLException

runStatements

protected void runStatements(Reader reader,
                             PrintStream out)
                      throws SQLException,
                             IOException
read in lines and execute them

Parameters:
reader - the reader
out - the outputstream
Throws:
SQLException
IOException

printResultSet

protected void printResultSet(ResultSet rs,
                              PrintStream out)
                       throws SQLException
print any results in the result set.

Parameters:
rs - the resultset to print information about
out - the place to print results
Throws:
SQLException - on SQL problems.

isKeepFormat

public boolean isKeepFormat()

setKeepFormat

public void setKeepFormat(boolean keepFormat)

getDelimiterType

public String getDelimiterType()

setDelimiterType

public void setDelimiterType(String delimiterType)

getDelimiter

public String getDelimiter()

setDelimiter

public void setDelimiter(String delimiter)

isPrintResultSet

public boolean isPrintResultSet()

setPrintResultSet

public void setPrintResultSet(boolean printResultSet)

getOnError

public String getOnError()

setOnError

public void setOnError(String onError)

isShowheaders

public boolean isShowheaders()

setShowheaders

public void setShowheaders(boolean showheaders)

getOutputDelimiter

public String getOutputDelimiter()

setOutputDelimiter

public void setOutputDelimiter(String outputDelimiter)

getTotalStatements

public int getTotalStatements()

setTotalStatements

public void setTotalStatements(int totalStatements)

getSuccessfulStatements

public int getSuccessfulStatements()

setSuccessfulStatements

public void setSuccessfulStatements(int successfulStatements)

getConn

public Connection getConn()

setConn

public void setConn(Connection conn)

getStatement

public Statement getStatement()

setStatement

public void setStatement(Statement statement)

isAutocommit

public boolean isAutocommit()

setAutocommit

public void setAutocommit(boolean autocommit)

isEscapeProcessing

public boolean isEscapeProcessing()

setEscapeProcessing

public void setEscapeProcessing(boolean escapeProcessing)

isAppend

public boolean isAppend()

setAppend

public void setAppend(boolean append)

isSkipOnConnectionError

public boolean isSkipOnConnectionError()

setSkipOnConnectionError

public void setSkipOnConnectionError(boolean skipOnConnectionError)

isConnectionError

public boolean isConnectionError()

setConnectionError

public void setConnectionError(boolean connectionError)

getListeners

public List<DatabaseListener> getListeners()

setListeners

public void setListeners(List<DatabaseListener> listeners)

getTransactions

public Vector<Transaction> getTransactions()

setTransactions

public void setTransactions(Vector<Transaction> transactions)


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.