com.sun.slamd.scripting.jdbc
Class JDBCResultSetVariable

java.lang.Object
  extended bycom.sun.slamd.scripting.engine.Variable
      extended bycom.sun.slamd.scripting.jdbc.JDBCResultSetVariable
All Implemented Interfaces:
Argument

public class JDBCResultSetVariable
extends Variable

This class defines a variable that provides a set of methods for interacting with the results of a query executed using a JDBC connection. The methods available for use with a result set are:


Field Summary
static java.lang.String CANCEL_ROW_UPDATES_METHOD_NAME
          The name of the method that can be used to cancel any outstanding updates to the current row of the result set.
static int CANCEL_ROW_UPDATES_METHOD_NUMBER
          The method number for the "cancelRowUpdates" method.
static java.lang.String DELETE_ROW_METHOD_NAME
          The name of the method that can be used to remove the current row from the result set and database.
static int DELETE_ROW_METHOD_NUMBER
          The method number for the "deleteRow" method.
static java.lang.String FIRST_ROW_METHOD_NAME
          The name of the method that can be used to move to the first row in the result set.
static int FIRST_ROW_METHOD_NUMBER
          The method number for the "firstRow" method.
static int GET_BOOLEAN_1_METHOD_NUMBER
          The method number for the first "getBoolean" method.
static int GET_BOOLEAN_2_METHOD_NUMBER
          The method number for the second "getBoolean" method.
static java.lang.String GET_BOOLEAN_METHOD_NAME
          The name of the method that can be used to retrieve the Boolean value of a specified column.
static java.lang.String GET_FAILURE_REASON_METHOD_NAME
          The name of the method that can retrieve the reason for the last failure.
static int GET_FAILURE_REASON_METHOD_NUMBER
          The method number for the "getFailureReason" method.
static int GET_INTEGER_1_METHOD_NUMBER
          The method number for the first "getInteger" method.
static int GET_INTEGER_2_METHOD_NUMBER
          The method number for the second "getInteger" method.
static java.lang.String GET_INTEGER_METHOD_NAME
          The name of the method that can be used to retrieve the integer value of a specified column.
static java.lang.String GET_ROW_METHOD_NAME
          The name of the method that can be used to get the row number for the current row.
static int GET_ROW_METHOD_NUMBER
          The method number for the "getRow" method.
static int GET_STRING_1_METHOD_NUMBER
          The method number for the first "getString" method.
static int GET_STRING_2_METHOD_NUMBER
          The method number for the second "getString" method.
static java.lang.String GET_STRING_METHOD_NAME
          The name of the method that can be used to retrieve the string value of a specified column.
static java.lang.String INSERT_ROW_METHOD_NAME
          The name of the method that can be used to insert a row into the row set and database.
static int INSERT_ROW_METHOD_NUMBER
          The method number for the "insertRow" method.
static java.lang.String IS_NULL_METHOD_NAME
          The name of the method that can be used to determine whether this is a null result set.
static int IS_NULL_METHOD_NUMBER
          The method number for the "isNull" method.
static Method[] JDBC_RESULT_SET_VARIABLE_METHODS
          The set of methods associated with JDBC result set variables.
static java.lang.String JDBC_RESULT_SET_VARIABLE_TYPE
          The name that will be used for the data type of JDBC result set variables.
static java.lang.String LAST_ROW_METHOD_NAME
          The name of the method that can be used to move to the last row in the result set.
static int LAST_ROW_METHOD_NUMBER
          The method number for the "lastRow" method.
static java.lang.String MOVE_TO_CURRENT_ROW_METHOD_NAME
          The name of the method that can be used to return to the row that was selected before moving to the insert row.
static int MOVE_TO_CURRENT_ROW_METHOD_NUMBER
          The method number for the "moveToCurrentRow" method.
static java.lang.String MOVE_TO_INSERT_ROW_METHOD_NAME
          The name of the method that can be used to move to a special row that can be used to insert a new row into the result set and database.
static int MOVE_TO_INSERT_ROW_METHOD_NUMBER
          The method number for the "moveToInsertRow" method.
static java.lang.String NEXT_ROW_METHOD_NAME
          The name of the method that can be used to move to the next row in the result set.
static int NEXT_ROW_METHOD_NUMBER
          The method number for the "nextRow" method.
static int SET_BOOLEAN_1_METHOD_NUMBER
          The method number for the first "setBoolean" method.
static int SET_BOOLEAN_2_METHOD_NUMBER
          The method number for the second "setBoolean" method.
static java.lang.String SET_BOOLEAN_METHOD_NAME
          The name of the method that can be used to specify the Boolean value to use for a given column of the current row.
static int SET_INTEGER_1_METHOD_NUMBER
          The method number for the first "setInteger" method.
static int SET_INTEGER_2_METHOD_NUMBER
          The method number for the second "setInteger" method.
static java.lang.String SET_INTEGER_METHOD_NAME
          The name of the method that can be used to specify the integer value to use for a given column of the current row.
static java.lang.String SET_ROW_METHOD_NAME
          The name of the method that can be used to specify the current row in the result set.
static int SET_ROW_METHOD_NUMBER
          The method number for the "setRow" method.
static int SET_STRING_1_METHOD_NUMBER
          The method number for the first "setString" method.
static int SET_STRING_2_METHOD_NUMBER
          The method number for the second "setString" method.
static java.lang.String SET_STRING_METHOD_NAME
          The name of the method that can be used to specify the string value to use for a given column of the current row.
static java.lang.String UPDATE_ROW_METHOD_NAME
          The name of the method that can be used to update the current row in the underlying database.
static int UPDATE_ROW_METHOD_NUMBER
          The method number for the "updateRow" method.
 
Constructor Summary
JDBCResultSetVariable()
          Creates a new variable with no name, to be used only when creating a variable with Class.newInstance(), and only when setName() is called after that to set the name.
JDBCResultSetVariable(java.lang.String sqlQuery, java.sql.ResultSet resultSet)
          Creates a new JDBC result set variable using the provided result set.
 
Method Summary
 void assign(Argument argument)
          Assigns the value of the provided argument to this variable.
 Variable executeMethod(int lineNumber, int methodNumber, Argument[] arguments)
          Executes the specified method, using the provided variables as arguments to the method, and makes the return value available to the caller.
 int getMethodNumber(java.lang.String methodName, java.lang.String[] argumentTypes)
          Retrieves the method number for the method that has the specified name and argument types, or -1 if there is no such method.
 Method[] getMethods()
          Retrieves a list of all methods defined for this variable.
 java.lang.String getReturnTypeForMethod(java.lang.String methodName, java.lang.String[] argumentTypes)
          Retrieves the return type for the method with the specified name and argument types.
 java.lang.String getValueAsString()
          Retrieves a string representation of the value of this argument.
 java.lang.String getVariableTypeName()
          Retrieves the name of the variable type for this variable.
 boolean hasMethod(java.lang.String methodName)
          Indicates whether this variable type has a method with the specified name.
 
Methods inherited from class com.sun.slamd.scripting.engine.Variable
getArgumentAsString, getArgumentType, getArgumentValue, getName, getStatTrackers, isValidIdentifier, setName, startStatTrackers, stopStatTrackers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JDBC_RESULT_SET_VARIABLE_TYPE

public static final java.lang.String JDBC_RESULT_SET_VARIABLE_TYPE
The name that will be used for the data type of JDBC result set variables.

See Also:
Constant Field Values

CANCEL_ROW_UPDATES_METHOD_NAME

public static final java.lang.String CANCEL_ROW_UPDATES_METHOD_NAME
The name of the method that can be used to cancel any outstanding updates to the current row of the result set.

See Also:
Constant Field Values

CANCEL_ROW_UPDATES_METHOD_NUMBER

public static final int CANCEL_ROW_UPDATES_METHOD_NUMBER
The method number for the "cancelRowUpdates" method.

See Also:
Constant Field Values

DELETE_ROW_METHOD_NAME

public static final java.lang.String DELETE_ROW_METHOD_NAME
The name of the method that can be used to remove the current row from the result set and database.

See Also:
Constant Field Values

DELETE_ROW_METHOD_NUMBER

public static final int DELETE_ROW_METHOD_NUMBER
The method number for the "deleteRow" method.

See Also:
Constant Field Values

FIRST_ROW_METHOD_NAME

public static final java.lang.String FIRST_ROW_METHOD_NAME
The name of the method that can be used to move to the first row in the result set.

See Also:
Constant Field Values

FIRST_ROW_METHOD_NUMBER

public static final int FIRST_ROW_METHOD_NUMBER
The method number for the "firstRow" method.

See Also:
Constant Field Values

GET_BOOLEAN_METHOD_NAME

public static final java.lang.String GET_BOOLEAN_METHOD_NAME
The name of the method that can be used to retrieve the Boolean value of a specified column.

See Also:
Constant Field Values

GET_BOOLEAN_1_METHOD_NUMBER

public static final int GET_BOOLEAN_1_METHOD_NUMBER
The method number for the first "getBoolean" method.

See Also:
Constant Field Values

GET_BOOLEAN_2_METHOD_NUMBER

public static final int GET_BOOLEAN_2_METHOD_NUMBER
The method number for the second "getBoolean" method.

See Also:
Constant Field Values

GET_FAILURE_REASON_METHOD_NAME

public static final java.lang.String GET_FAILURE_REASON_METHOD_NAME
The name of the method that can retrieve the reason for the last failure.

See Also:
Constant Field Values

GET_FAILURE_REASON_METHOD_NUMBER

public static final int GET_FAILURE_REASON_METHOD_NUMBER
The method number for the "getFailureReason" method.

See Also:
Constant Field Values

GET_INTEGER_METHOD_NAME

public static final java.lang.String GET_INTEGER_METHOD_NAME
The name of the method that can be used to retrieve the integer value of a specified column.

See Also:
Constant Field Values

GET_INTEGER_1_METHOD_NUMBER

public static final int GET_INTEGER_1_METHOD_NUMBER
The method number for the first "getInteger" method.

See Also:
Constant Field Values

GET_INTEGER_2_METHOD_NUMBER

public static final int GET_INTEGER_2_METHOD_NUMBER
The method number for the second "getInteger" method.

See Also:
Constant Field Values

GET_ROW_METHOD_NAME

public static final java.lang.String GET_ROW_METHOD_NAME
The name of the method that can be used to get the row number for the current row.

See Also:
Constant Field Values

GET_ROW_METHOD_NUMBER

public static final int GET_ROW_METHOD_NUMBER
The method number for the "getRow" method.

See Also:
Constant Field Values

GET_STRING_METHOD_NAME

public static final java.lang.String GET_STRING_METHOD_NAME
The name of the method that can be used to retrieve the string value of a specified column.

See Also:
Constant Field Values

GET_STRING_1_METHOD_NUMBER

public static final int GET_STRING_1_METHOD_NUMBER
The method number for the first "getString" method.

See Also:
Constant Field Values

GET_STRING_2_METHOD_NUMBER

public static final int GET_STRING_2_METHOD_NUMBER
The method number for the second "getString" method.

See Also:
Constant Field Values

INSERT_ROW_METHOD_NAME

public static final java.lang.String INSERT_ROW_METHOD_NAME
The name of the method that can be used to insert a row into the row set and database.

See Also:
Constant Field Values

INSERT_ROW_METHOD_NUMBER

public static final int INSERT_ROW_METHOD_NUMBER
The method number for the "insertRow" method.

See Also:
Constant Field Values

IS_NULL_METHOD_NAME

public static final java.lang.String IS_NULL_METHOD_NAME
The name of the method that can be used to determine whether this is a null result set.

See Also:
Constant Field Values

IS_NULL_METHOD_NUMBER

public static final int IS_NULL_METHOD_NUMBER
The method number for the "isNull" method.

See Also:
Constant Field Values

LAST_ROW_METHOD_NAME

public static final java.lang.String LAST_ROW_METHOD_NAME
The name of the method that can be used to move to the last row in the result set.

See Also:
Constant Field Values

LAST_ROW_METHOD_NUMBER

public static final int LAST_ROW_METHOD_NUMBER
The method number for the "lastRow" method.

See Also:
Constant Field Values

MOVE_TO_CURRENT_ROW_METHOD_NAME

public static final java.lang.String MOVE_TO_CURRENT_ROW_METHOD_NAME
The name of the method that can be used to return to the row that was selected before moving to the insert row.

See Also:
Constant Field Values

MOVE_TO_CURRENT_ROW_METHOD_NUMBER

public static final int MOVE_TO_CURRENT_ROW_METHOD_NUMBER
The method number for the "moveToCurrentRow" method.

See Also:
Constant Field Values

MOVE_TO_INSERT_ROW_METHOD_NAME

public static final java.lang.String MOVE_TO_INSERT_ROW_METHOD_NAME
The name of the method that can be used to move to a special row that can be used to insert a new row into the result set and database.

See Also:
Constant Field Values

MOVE_TO_INSERT_ROW_METHOD_NUMBER

public static final int MOVE_TO_INSERT_ROW_METHOD_NUMBER
The method number for the "moveToInsertRow" method.

See Also:
Constant Field Values

NEXT_ROW_METHOD_NAME

public static final java.lang.String NEXT_ROW_METHOD_NAME
The name of the method that can be used to move to the next row in the result set.

See Also:
Constant Field Values

NEXT_ROW_METHOD_NUMBER

public static final int NEXT_ROW_METHOD_NUMBER
The method number for the "nextRow" method.

See Also:
Constant Field Values

SET_BOOLEAN_METHOD_NAME

public static final java.lang.String SET_BOOLEAN_METHOD_NAME
The name of the method that can be used to specify the Boolean value to use for a given column of the current row.

See Also:
Constant Field Values

SET_BOOLEAN_1_METHOD_NUMBER

public static final int SET_BOOLEAN_1_METHOD_NUMBER
The method number for the first "setBoolean" method.

See Also:
Constant Field Values

SET_BOOLEAN_2_METHOD_NUMBER

public static final int SET_BOOLEAN_2_METHOD_NUMBER
The method number for the second "setBoolean" method.

See Also:
Constant Field Values

SET_INTEGER_METHOD_NAME

public static final java.lang.String SET_INTEGER_METHOD_NAME
The name of the method that can be used to specify the integer value to use for a given column of the current row.

See Also:
Constant Field Values

SET_INTEGER_1_METHOD_NUMBER

public static final int SET_INTEGER_1_METHOD_NUMBER
The method number for the first "setInteger" method.

See Also:
Constant Field Values

SET_INTEGER_2_METHOD_NUMBER

public static final int SET_INTEGER_2_METHOD_NUMBER
The method number for the second "setInteger" method.

See Also:
Constant Field Values

SET_ROW_METHOD_NAME

public static final java.lang.String SET_ROW_METHOD_NAME
The name of the method that can be used to specify the current row in the result set.

See Also:
Constant Field Values

SET_ROW_METHOD_NUMBER

public static final int SET_ROW_METHOD_NUMBER
The method number for the "setRow" method.

See Also:
Constant Field Values

SET_STRING_METHOD_NAME

public static final java.lang.String SET_STRING_METHOD_NAME
The name of the method that can be used to specify the string value to use for a given column of the current row.

See Also:
Constant Field Values

SET_STRING_1_METHOD_NUMBER

public static final int SET_STRING_1_METHOD_NUMBER
The method number for the first "setString" method.

See Also:
Constant Field Values

SET_STRING_2_METHOD_NUMBER

public static final int SET_STRING_2_METHOD_NUMBER
The method number for the second "setString" method.

See Also:
Constant Field Values

UPDATE_ROW_METHOD_NAME

public static final java.lang.String UPDATE_ROW_METHOD_NAME
The name of the method that can be used to update the current row in the underlying database.

See Also:
Constant Field Values

UPDATE_ROW_METHOD_NUMBER

public static final int UPDATE_ROW_METHOD_NUMBER
The method number for the "updateRow" method.

See Also:
Constant Field Values

JDBC_RESULT_SET_VARIABLE_METHODS

public static final Method[] JDBC_RESULT_SET_VARIABLE_METHODS
The set of methods associated with JDBC result set variables.

Constructor Detail

JDBCResultSetVariable

public JDBCResultSetVariable()
                      throws ScriptException
Creates a new variable with no name, to be used only when creating a variable with Class.newInstance(), and only when setName() is called after that to set the name.

Throws:
ScriptException - If a problem occurs while initializing the new variable.

JDBCResultSetVariable

public JDBCResultSetVariable(java.lang.String sqlQuery,
                             java.sql.ResultSet resultSet)
Creates a new JDBC result set variable using the provided result set.

Parameters:
sqlQuery - The SQL query to use for this result set variable.
resultSet - The JDBC result set to use for this result set variable.
Method Detail

getVariableTypeName

public java.lang.String getVariableTypeName()
Retrieves the name of the variable type for this variable.

Specified by:
getVariableTypeName in class Variable
Returns:
The name of the variable type for this variable.

getMethods

public Method[] getMethods()
Retrieves a list of all methods defined for this variable.

Specified by:
getMethods in class Variable
Returns:
A list of all methods defined for this variable.

hasMethod

public boolean hasMethod(java.lang.String methodName)
Indicates whether this variable type has a method with the specified name.

Specified by:
hasMethod in class Variable
Parameters:
methodName - The name of the method.
Returns:
true if this variable has a method with the specified name, or false if it does not.

getMethodNumber

public int getMethodNumber(java.lang.String methodName,
                           java.lang.String[] argumentTypes)
Retrieves the method number for the method that has the specified name and argument types, or -1 if there is no such method.

Specified by:
getMethodNumber in class Variable
Parameters:
methodName - The name of the method.
argumentTypes - The list of argument types for the method.
Returns:
The method number for the method that has the specified name and argument types.

getReturnTypeForMethod

public java.lang.String getReturnTypeForMethod(java.lang.String methodName,
                                               java.lang.String[] argumentTypes)
Retrieves the return type for the method with the specified name and argument types.

Specified by:
getReturnTypeForMethod in class Variable
Parameters:
methodName - The name of the method.
argumentTypes - The set of argument types for the method.
Returns:
The return type for the method, or null if there is no such method defined.

executeMethod

public Variable executeMethod(int lineNumber,
                              int methodNumber,
                              Argument[] arguments)
                       throws ScriptException
Executes the specified method, using the provided variables as arguments to the method, and makes the return value available to the caller.

Specified by:
executeMethod in class Variable
Parameters:
lineNumber - The line number of the script in which the method call occurs.
methodNumber - The method number of the method to execute.
arguments - The set of arguments to use for the method.
Returns:
The value returned from the method, or null if it does not return a value.
Throws:
ScriptException - If the specified method does not exist, or if a problem occurs while attempting to execute it.

assign

public void assign(Argument argument)
            throws ScriptException
Assigns the value of the provided argument to this variable. The value of the provided argument must be of the same type as this variable.

Specified by:
assign in class Variable
Parameters:
argument - The argument whose value should be assigned to this variable.
Throws:
ScriptException - If a problem occurs while performing the assignment.

getValueAsString

public java.lang.String getValueAsString()
Retrieves a string representation of the value of this argument.

Returns:
A string representation of the value of this argument.