uk.org.ogsadai.activity.sql.statement
Class CallableSQLStatement

java.lang.Object
  |
  +--uk.org.ogsadai.activity.sql.statement.ParameterisedSQLStatement
        |
        +--uk.org.ogsadai.activity.sql.statement.CallableSQLStatement
All Implemented Interfaces:
SQLStatement

public class CallableSQLStatement
extends ParameterisedSQLStatement

Executes callable SQL statements.

Author:
The OGSA-DAI Project Team.

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private static DAILogger LOG
          Logger object for logging in this class
private  boolean mFinishedProcessing
          Has expression completed (default false)
private  boolean mFirstCall
          Has the first call been made?
private  boolean mNewCall
          Has a new call been made?
private  java.util.Map mOutParams
          Output parameters for the callable SQL statement
private  int mUpdateCount
          Current update count from statement execution
 
Fields inherited from class uk.org.ogsadai.activity.sql.statement.ParameterisedSQLStatement
mStatement
 
Constructor Summary
CallableSQLStatement()
          Constructor
CallableSQLStatement(java.sql.Connection conx, ParameterList parameters, java.lang.String expression)
          Constructor.
 
Method Summary
 boolean execute()
          Executes an SQL callable statement.
 boolean getMoreResults()
          Get more results from the SQL statement.
 java.sql.ResultSet getNextResultSet()
          Gets the next ResultSet if there is one
 int getNextUpdateCount()
          Gets the next update count if there is one
 java.util.Map getOutParameters()
          Gets the output parameters after a new execute
 void initialise()
          Initialise the SQL statement.
 void registerOutParameter(int position, int type)
          Register an output parameter for the callable SQL statement.
private  void registerOutParameters()
          Registers all out parameters with a JDBC callable statement handler
 
Methods inherited from class uk.org.ogsadai.activity.sql.statement.ParameterisedSQLStatement
close, closeTempFilesAndInputStreams, executeQuery, executeUpdate, getConnection, getExpression, getParameters, prepareParameters, setConnection, setExpression, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

LOG

private static DAILogger LOG
Logger object for logging in this class


mFinishedProcessing

private boolean mFinishedProcessing
Has expression completed (default false)


mUpdateCount

private int mUpdateCount
Current update count from statement execution


mFirstCall

private boolean mFirstCall
Has the first call been made?


mOutParams

private java.util.Map mOutParams
Output parameters for the callable SQL statement


mNewCall

private boolean mNewCall
Has a new call been made?

Constructor Detail

CallableSQLStatement

public CallableSQLStatement()
Constructor


CallableSQLStatement

public CallableSQLStatement(java.sql.Connection conx,
                            ParameterList parameters,
                            java.lang.String expression)
                     throws java.sql.SQLException
Constructor.

Parameters:
conx - JDBC connection
parameters - A list of parameters
expression - SQL expression
Throws:
java.sql.SQLException - If the statement could not be prepared
Method Detail

initialise

public void initialise()
                throws java.sql.SQLException
Description copied from interface: SQLStatement
Initialise the SQL statement.

Specified by:
initialise in interface SQLStatement
Overrides:
initialise in class ParameterisedSQLStatement
Throws:
java.sql.SQLException - If any problem occurs in the driver.

registerOutParameter

public void registerOutParameter(int position,
                                 int type)
Register an output parameter for the callable SQL statement.

Parameters:
position - Parameter position
type - JDBC output parameter type.

execute

public boolean execute()
                throws java.sql.SQLException,
                       MissingParametersException,
                       ParameterAccessException
Executes an SQL callable statement.

Returns:
-1 if there are no more parameters, 0 if the first result is an update count or 1 if the first result is a ResultSet.
Throws:
java.sql.SQLException - If any problem occurs in the driver.
MissingParametersException - If some of the parameters provided all their values yet others did not.
ParameterAccessException - If there is a problem when accessing a parameter value.

getMoreResults

public boolean getMoreResults()
                       throws java.sql.SQLException,
                              MissingParametersException,
                              ParameterAccessException
Get more results from the SQL statement. There are no more results if getMoreResults returns false and getNextUpdateCount returns -1.

Returns:
true if the next result is a ResultSet, false otherwise.
Throws:
java.sql.SQLException - If any problem occurs in the driver.
MissingParametersException - If some of the parameters provided all their values yet others did not.
ParameterAccessException - If there is a problem when accessing a parameter value.

getNextResultSet

public java.sql.ResultSet getNextResultSet()
                                    throws java.sql.SQLException
Gets the next ResultSet if there is one

Returns:
a ResultSet or null if there are no more results.
Throws:
java.sql.SQLException - If any problem occurs in the driver.

getNextUpdateCount

public int getNextUpdateCount()
                       throws java.sql.SQLException
Gets the next update count if there is one

Returns:
an update count or -1 if there are no more results
Throws:
java.sql.SQLException - If any problem occurs in the driver.

getOutParameters

public java.util.Map getOutParameters()
                               throws java.sql.SQLException
Gets the output parameters after a new execute

Returns:
output parameters mapped by parameter number
Throws:
java.sql.SQLException - If any problem occurs in the driver.

registerOutParameters

private void registerOutParameters()
                            throws java.sql.SQLException
Registers all out parameters with a JDBC callable statement handler

Throws:
java.sql.SQLException - If any problem occurs in the driver.