uk.org.ogsadai.client.toolkit.activity.sql
Class SQLQuery

java.lang.Object
  |
  +--uk.org.ogsadai.client.toolkit.activity.RequestComponent
        |
        +--uk.org.ogsadai.client.toolkit.activity.Activity
              |
              +--uk.org.ogsadai.client.toolkit.activity.ParameterizedActivity
                    |
                    +--uk.org.ogsadai.client.toolkit.activity.sql.SQLQuery

public class SQLQuery
extends ParameterizedActivity

This activity evaluates an SQL statement that generates a single java.sql.ResultSet.

The activity has no inputs and one outputs - the ResultSet.

The format output can only be streamed to other activities. For delivery in the response the output from this activity should be connected as an input to the WebRowSet activity which will convert the ResultSet into an XML WebRowSet representation of the ResultSet.

Queries can be parameterized by using the ? token in the query expression. These tokens can be replaced with parameter values hence allowing an activity to be reused with a slightly different configuration.

For example, the activity may have the following query expression:
SELECT * FROM MyTable WHERE id > ? AND id < ?
This query has two parameters whose values can be set using the setParameter method, for example: myActivity.setParameter( 1, "10" );
myActivity.setParameter( 2, "20" );
Would be equivalent to the query expression:
SELECT * FROM MyTable WHERE id > 10 AND id < 20

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private  java.lang.String mQuery
          SQL query
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.ParameterizedActivity
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.Activity
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
 
Constructor Summary
SQLQuery(java.lang.String expression)
          Constructs a query with the given query expression.
 
Method Summary
protected  java.lang.String generateXML()
          Generates the XML representing the activity.
 java.lang.String getExpression()
          Gets the SQL query expression.
 ActivityOutput getOutput()
          Gets the activity's only output.
 void setExpression(java.lang.String expression)
          Sets the SQL expression.
 
Methods inherited from class uk.org.ogsadai.client.toolkit.activity.ParameterizedActivity
clearParameters, generateParametersXML, setParameter, setParameter
 
Methods inherited from class uk.org.ogsadai.client.toolkit.activity.Activity
addInput, addOutput, addOutputs, getDataResourceID, getInputParameters, getOutputParameters, getOutputs, replaceSpecialCharacters, setDataResourceID, setInput
 
Methods inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
getDataService, getName, getSession, setDataService, setSession
 
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

mQuery

private java.lang.String mQuery
SQL query

Constructor Detail

SQLQuery

public SQLQuery(java.lang.String expression)
Constructs a query with the given query expression.

Parameters:
expression - SQL query.
Throws:
java.lang.IllegalArgumentException - If expression is null.
Method Detail

setExpression

public void setExpression(java.lang.String expression)
Sets the SQL expression.

Parameters:
expression - SQL query.
Throws:
java.lang.IllegalArgumentException - If expression is null.

getExpression

public java.lang.String getExpression()
Gets the SQL query expression.

Returns:
the SQL query expression

getOutput

public ActivityOutput getOutput()
Gets the activity's only output.

Returns:
the activity output.

generateXML

protected java.lang.String generateXML()
Description copied from class: RequestComponent
Generates the XML representing the activity. This XML can then be inserted into a perform document that is sent to a data service.

Specified by:
generateXML in class Activity
Returns:
the XML for the activity