net.sourceforge.sqlunit.handlers
Class CallHandler

java.lang.Object
  extended by net.sourceforge.sqlunit.handlers.SqlHandler
      extended by net.sourceforge.sqlunit.handlers.CallHandler
All Implemented Interfaces:
IHandler

public class CallHandler
extends SqlHandler

The CallHandler class processes the contents of a call tag in the input XML file.

Version:
$Revision: 1.15 $
Author:
Sujit Pal (spal@users.sourceforge.net)

Constructor Summary
CallHandler()
           
 
Method Summary
protected  java.sql.Statement acquireStatementObject(java.sql.Connection conn, java.lang.String stmt)
          Overrides the parent method to build a CallableStatement object from the Connection and SQL string.
protected  void clrOutputParameters(java.sql.Statement cs, Param[] params)
          Overrides the parent method to clear parameters in the DatabaseResult object.
protected  boolean isMoreResultsAvailable(boolean hasResults, int rowsUpdated)
          Overrides the parent method to return true if more results are available.
 java.lang.Object process(org.jdom.Element elCall)
          Runs the SQL Stored Procedure contained in the call tag in the input XML file.
protected  void setOutputParameters(java.sql.Statement cs, Param[] params, DatabaseResult result)
          Overrides the parent method to set the OUT parameters into the DatabaseResult object.
protected  java.sql.Statement setParameters(java.sql.Statement cs, Param[] params)
          Overrides the parent method to set replaceable parameters, if any, into the CallableStatement object.
 
Methods inherited from class net.sourceforge.sqlunit.handlers.SqlHandler
acquireConnection, executeQuery, executeSQL, initDatabaseResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CallHandler

public CallHandler()
Method Detail

process

public final java.lang.Object process(org.jdom.Element elCall)
                               throws java.lang.Exception
Runs the SQL Stored Procedure contained in the call tag in the input XML file. Returns a DatabaseResult object.

Specified by:
process in interface IHandler
Overrides:
process in class SqlHandler
Parameters:
elCall - the JDOM Element representing the call tag.
Returns:
the DatabaseResult returned from executing the stored procedure.
Throws:
java.lang.Exception - if there was a problem running the SQL.

acquireStatementObject

protected final java.sql.Statement acquireStatementObject(java.sql.Connection conn,
                                                          java.lang.String stmt)
                                                   throws java.lang.Exception
Overrides the parent method to build a CallableStatement object from the Connection and SQL string.

Overrides:
acquireStatementObject in class SqlHandler
Parameters:
conn - the Connection object.
stmt - the SQL string.
Returns:
a Statement object.
Throws:
java.lang.Exception - if there was a problem building the Statement.

setParameters

protected final java.sql.Statement setParameters(java.sql.Statement cs,
                                                 Param[] params)
                                          throws java.lang.Exception
Overrides the parent method to set replaceable parameters, if any, into the CallableStatement object. CallableStatements may have to register OUT parameters, as well as set IN and INOUT parameters.

Overrides:
setParameters in class SqlHandler
Parameters:
cs - the Statement object.
params - the array of Param objects.
Returns:
a Statement object which should be cast to CallableStatement.
Throws:
java.lang.Exception - if there was a problem setting the parameters.

isMoreResultsAvailable

protected final boolean isMoreResultsAvailable(boolean hasResults,
                                               int rowsUpdated)
Overrides the parent method to return true if more results are available. CallableStatements may return multiple result sets, so this test actually ORs the values it is passed in.

Overrides:
isMoreResultsAvailable in class SqlHandler
Parameters:
hasResults - boolean generated from cs.execute().
rowsUpdated - int generated from cs.getUpdateCount().
Returns:
true if there are more resultsets, else false.

setOutputParameters

protected final void setOutputParameters(java.sql.Statement cs,
                                         Param[] params,
                                         DatabaseResult result)
                                  throws java.lang.Exception
Overrides the parent method to set the OUT parameters into the DatabaseResult object.

Overrides:
setOutputParameters in class SqlHandler
Parameters:
cs - the Statement object.
params - the array of Param objects.
result - the DatabaseResult object.
Throws:
java.lang.Exception - if there was a problem setting the OUT params.

clrOutputParameters

protected final void clrOutputParameters(java.sql.Statement cs,
                                         Param[] params)
                                  throws java.lang.Exception
Overrides the parent method to clear parameters in the DatabaseResult object.

Overrides:
clrOutputParameters in class SqlHandler
Parameters:
cs - the Statement object.
params - the array of Param objects.
Throws:
java.lang.Exception - if there was a problem clearing the out parameters.