Package org.oddjob.sql
Class ParameterisedExecutor
java.lang.Object
org.oddjob.sql.ParameterisedExecutor
- All Implemented Interfaces:
ExceptionListener,AutoCloseable,Runnable,Consumer<String>,ArooaSessionAware
public class ParameterisedExecutor
extends Object
implements Consumer<String>, ArooaSessionAware, Runnable, AutoCloseable, ExceptionListener
Handles the execution of a single SQL statement at a time.
- Author:
- rob
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclose()voidvoidExecute the SQL statement.intGetter for executedSQLCount.getParameters(int index) Get parameter by index.intGetter for successful SQL count.booleanGetter for autocommit.booleanGetter for callable statement flag.booleanGetter for escapeProcessing.voidrun()voidsetArooaSession(ArooaSession session) Accept the current Arooa Session.voidsetAutocommit(boolean autocommit) Auto commit flag for database connection; optional, default false.voidsetBeanBus(Flushable busConductor) voidsetCallable(boolean callable) Setter for callable statement flag.voidsetConnection(Connection connection) Set the connection to use.voidsetDialect(DatabaseDialect dialect) voidsetEscapeProcessing(boolean escapeProcessing) Setter for escapeProcessing.voidsetParameters(int index, ValueType parameter) Set parameter by index.voidsetResultProcessor(SQLResultHandler processor) Set the result processor.
-
Constructor Details
-
ParameterisedExecutor
public ParameterisedExecutor()
-
-
Method Details
-
setArooaSession
Description copied from interface:ArooaSessionAwareAccept the current Arooa Session.- Specified by:
setArooaSessionin interfaceArooaSessionAware- Parameters:
session- The Arooa Session. Never null.
-
run
public void run() -
exceptionThrown
- Specified by:
exceptionThrownin interfaceExceptionListener
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
FailedToStopException
-
accept
-
execute
public void execute(String sql) throws SQLException, ArooaConversionException, BusException, ClassNotFoundException Execute the SQL statement.- Parameters:
sql- the SQL statement to execute- Throws:
SQLException- on SQL problemsConversionFailedExceptionNoConversionAvailableExceptionBusExceptionClassNotFoundExceptionArooaConversionException
-
setBeanBus
-
setResultProcessor
Set the result processor.- Parameters:
processor- The result processor to pass results to.
-
setConnection
Set the connection to use. This will be closed when the bus is stopped.- Parameters:
connection- The connection.
-
setAutocommit
public void setAutocommit(boolean autocommit) Auto commit flag for database connection; optional, default false.- Parameters:
autocommit- The autocommit to set
-
isAutocommit
public boolean isAutocommit()Getter for autocommit.- Returns:
- autocommit flag.
-
isEscapeProcessing
public boolean isEscapeProcessing()Getter for escapeProcessing.- Returns:
- escapeProcessing flag.
-
setEscapeProcessing
public void setEscapeProcessing(boolean escapeProcessing) Setter for escapeProcessing.- Parameters:
escapeProcessing- escapeProcessing flag.
-
getParameters
Get parameter by index.- Parameters:
index- The index.- Returns:
- The parameter or null.
- Throws:
IndexOutOfBoundsException
-
setParameters
Set parameter by index.- Parameters:
index- The index.parameter- The parameter. Null to remove.- Throws:
IndexOutOfBoundsException
-
isCallable
public boolean isCallable()Getter for callable statement flag.- Returns:
- The callable flag.
-
setCallable
public void setCallable(boolean callable) Setter for callable statement flag.- Parameters:
callable- The callable flag.
-
getExecutedSQLCount
public int getExecutedSQLCount()Getter for executedSQLCount.- Returns:
- The number of SQL statements executed.
-
getSuccessfulSQLCount
public int getSuccessfulSQLCount()Getter for successful SQL count.- Returns:
- The number of SQL statements successfully executed.
-
getDialect
-
setDialect
-