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 Details

    • ParameterisedExecutor

      public ParameterisedExecutor()
  • Method Details

    • setArooaSession

      public void setArooaSession(ArooaSession session)
      Description copied from interface: ArooaSessionAware
      Accept the current Arooa Session.
      Specified by:
      setArooaSession in interface ArooaSessionAware
      Parameters:
      session - The Arooa Session. Never null.
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • exceptionThrown

      public void exceptionThrown(Exception e)
      Specified by:
      exceptionThrown in interface ExceptionListener
    • close

      public void close() throws FailedToStopException
      Specified by:
      close in interface AutoCloseable
      Throws:
      FailedToStopException
    • accept

      public void accept(String sql)
      Specified by:
      accept in interface Consumer<String>
    • execute

      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(Flushable 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)