org.oddjob.sql
Class ParameterisedExecutor

java.lang.Object
  extended by org.oddjob.beanbus.AbstractDestination<String>
      extended by org.oddjob.sql.ParameterisedExecutor
All Implemented Interfaces:
Iterable<String>, Collection<String>, ArooaSessionAware

public class ParameterisedExecutor
extends AbstractDestination<String>
implements ArooaSessionAware

Handles the execution of a single SQL statement at a time.

Author:
rob

Constructor Summary
ParameterisedExecutor()
           
 
Method Summary
 boolean add(String sql)
           
 void execute(String sql)
          Execute the SQL statement.
 DatabaseDialect getDialect()
           
 int getExecutedSQLCount()
          Getter for executedSQLCount.
 ValueType getParameters(int index)
          Get parameter by index.
 int getSuccessfulSQLCount()
          Getter for successful SQL count.
 boolean isAutocommit()
          Getter for autocommit.
 boolean isCallable()
          Getter for callable statement flag.
 boolean isEscapeProcessing()
          Getter for escapeProcessing.
 void setArooaSession(ArooaSession session)
           
 void setAutocommit(boolean autocommit)
          Auto commit flag for database connection; optional, default false.
 void setBeanBus(BusConductor busConductor)
           
 void setCallable(boolean callable)
          Setter for callable statement flag.
 void setConnection(Connection connection)
          Set the connection to use.
 void setDialect(DatabaseDialect dialect)
           
 void setEscapeProcessing(boolean escapeProcessing)
          Setter for escapeProcessing.
 void setParameters(int index, ValueType parameter)
          Set parameter by index.
 void setResultProcessor(SQLResultHandler processor)
          Set the result processor.
 
Methods inherited from class org.oddjob.beanbus.AbstractDestination
addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

ParameterisedExecutor

public ParameterisedExecutor()
Method Detail

setArooaSession

public void setArooaSession(ArooaSession session)
Specified by:
setArooaSession in interface ArooaSessionAware

add

public boolean add(String sql)
Specified by:
add in interface Collection<String>

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 problems
ConversionFailedException
NoConversionAvailableException
BusException
ClassNotFoundException
ArooaConversionException

setBeanBus

@Inject
public void setBeanBus(BusConductor busConductor)

setResultProcessor

public void setResultProcessor(SQLResultHandler processor)
Set the result processor.

Parameters:
processor - The result processor to pass results to.

setConnection

public void setConnection(Connection connection)
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

public ValueType getParameters(int index)
                        throws IndexOutOfBoundsException
Get parameter by index.

Parameters:
index - The index.
Returns:
The parameter or null.
Throws:
IndexOutOfBoundsException

setParameters

public void setParameters(int index,
                          ValueType parameter)
                   throws IndexOutOfBoundsException
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

public DatabaseDialect getDialect()

setDialect

public void setDialect(DatabaseDialect dialect)