com.sun.slamd.scripting.jdbc
Class JDBCConnectionVariable

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

public class JDBCConnectionVariable
extends Variable

This class defines a variable that provides an interface to the JDBC Connection object that can be used to interact with relational databases. A JDBC connection variable provides the following methods:


Field Summary
static java.lang.String COMMIT_METHOD_NAME
          The name of the method that can be used to commit outstanding changes to the database.
static int COMMIT_METHOD_NUMBER
          The method number for the "commit" method.
static int CONNECT_1_METHOD_NUMBER
          The method number for the first "connect" method.
static int CONNECT_2_METHOD_NUMBER
          The method number for the second "connect" method.
static java.lang.String CONNECT_METHOD_NAME
          The name of the method that can be used to establish connections to a database.
static java.lang.String DISCONNECT_METHOD_NAME
          The name of the method that can be used to disconnect from the database.
static int DISCONNECT_METHOD_NUMBER
          The method number for the "close" method.
static java.lang.String EXECUTE_QUERY_METHOD_NAME
          The name of the method that can be used to execute a query in the database.
static int EXECUTE_QUERY_METHOD_NUMBER
          The method number for the "executeQuery" method.
static java.lang.String EXECUTE_UPDATE_METHOD_NAME
          The name of the method that can be used to execute an update in the database.
static int EXECUTE_UPDATE_METHOD_NUMBER
          The method number for the "executeUpdate" method.
static java.lang.String GET_AUTO_COMMIT_METHOD_NAME
          The name of the method that can be used to determine whether autocommit is enabled in the database.
static int GET_AUTO_COMMIT_METHOD_NUMBER
          The method number for the "getAutoCommit" method.
static java.lang.String GET_FAILURE_REASON_METHOD_NAME
          The name of the method that can be used to retrieve information about the reason that the last operation failed.
static int GET_FAILURE_REASON_METHOD_NUMBER
          The method number for the "getFailureReason" method.
static java.lang.String GET_LOGIN_TIMEOUT_METHOD_NAME
          The name of the method that can be used to retrieve the login timeout that has been configured.
static int GET_LOGIN_TIMEOUT_METHOD_NUMBER
          The method number for the "getLoginTimeout" method.
static java.lang.String GET_QUERY_TIMEOUT_METHOD_NAME
          The name of the method that can be used to retrieve the query timeout that has been configured.
static int GET_QUERY_TIMEOUT_METHOD_NUMBER
          The method number for the "getQueryTimeout" method.
static java.lang.String IS_CONNECTED_METHOD_NAME
          The name of the method that can be used to determine whether this connection is currently established.
static int IS_CONNECTED_METHOD_NUMBER
          The method number for the "isConnected" method.
static Method[] JDBC_CONNECTION_VARIABLE_METHODS
          The set of methods associated with JDBC connection variables.
static java.lang.String JDBC_CONNECTION_VARIABLE_TYPE
          The name that will be used for the data type of JDBC connection variables.
static java.lang.String PREPARE_STATEMENT_METHOD_NAME
          The name of the method that can be used to create a prepared statement.
static int PREPARE_STATEMENT_METHOD_NUMBER
          The method number for the "prepareStatement" method.
static java.lang.String ROLL_BACK_METHOD_NAME
          The name of the method that can be used to roll back any outstanding changes.
static int ROLL_BACK_METHOD_NUMBER
          The method number for the "rollBack" method.
static java.lang.String SET_AUTO_COMMIT_METHOD_NAME
          The name of the method that can be used to enable or disable autocommit in the database.
static int SET_AUTO_COMMIT_METHOD_NUMBR
          The method number for the "setAutoCommit" method.
static java.lang.String SET_DRIVER_CLASS_METHOD_NAME
          The name of the method that can be used to specify the JDBC driver class to use.
static int SET_DRIVER_CLASS_METHOD_NUMBER
          The method number for the "setDriverClass" method.
static java.lang.String SET_LOGIN_TIMEOUT_METHOD_NAME
          The name of the method that can be used to specify the login timeout.
static int SET_LOGIN_TIMEOUT_METHOD_NUMBER
          The method number for the "setLoginTimeout" method.
static java.lang.String SET_QUERY_TIMEOUT_METHOD_NAME
          The name of the method that can be used to specify the query timeout.
static int SET_QUERY_TIMEOUT_METHOD_NUMBER
          The method number for the "setQueryTimeout" method.
 
Constructor Summary
JDBCConnectionVariable()
          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.
 
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_CONNECTION_VARIABLE_TYPE

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

See Also:
Constant Field Values

COMMIT_METHOD_NAME

public static final java.lang.String COMMIT_METHOD_NAME
The name of the method that can be used to commit outstanding changes to the database.

See Also:
Constant Field Values

COMMIT_METHOD_NUMBER

public static final int COMMIT_METHOD_NUMBER
The method number for the "commit" method.

See Also:
Constant Field Values

CONNECT_METHOD_NAME

public static final java.lang.String CONNECT_METHOD_NAME
The name of the method that can be used to establish connections to a database.

See Also:
Constant Field Values

CONNECT_1_METHOD_NUMBER

public static final int CONNECT_1_METHOD_NUMBER
The method number for the first "connect" method.

See Also:
Constant Field Values

CONNECT_2_METHOD_NUMBER

public static final int CONNECT_2_METHOD_NUMBER
The method number for the second "connect" method.

See Also:
Constant Field Values

DISCONNECT_METHOD_NAME

public static final java.lang.String DISCONNECT_METHOD_NAME
The name of the method that can be used to disconnect from the database.

See Also:
Constant Field Values

DISCONNECT_METHOD_NUMBER

public static final int DISCONNECT_METHOD_NUMBER
The method number for the "close" method.

See Also:
Constant Field Values

EXECUTE_QUERY_METHOD_NAME

public static final java.lang.String EXECUTE_QUERY_METHOD_NAME
The name of the method that can be used to execute a query in the database.

See Also:
Constant Field Values

EXECUTE_QUERY_METHOD_NUMBER

public static final int EXECUTE_QUERY_METHOD_NUMBER
The method number for the "executeQuery" method.

See Also:
Constant Field Values

EXECUTE_UPDATE_METHOD_NAME

public static final java.lang.String EXECUTE_UPDATE_METHOD_NAME
The name of the method that can be used to execute an update in the database.

See Also:
Constant Field Values

EXECUTE_UPDATE_METHOD_NUMBER

public static final int EXECUTE_UPDATE_METHOD_NUMBER
The method number for the "executeUpdate" method.

See Also:
Constant Field Values

GET_AUTO_COMMIT_METHOD_NAME

public static final java.lang.String GET_AUTO_COMMIT_METHOD_NAME
The name of the method that can be used to determine whether autocommit is enabled in the database.

See Also:
Constant Field Values

GET_AUTO_COMMIT_METHOD_NUMBER

public static final int GET_AUTO_COMMIT_METHOD_NUMBER
The method number for the "getAutoCommit" 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 be used to retrieve information about the reason that the last operation failed.

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_LOGIN_TIMEOUT_METHOD_NAME

public static final java.lang.String GET_LOGIN_TIMEOUT_METHOD_NAME
The name of the method that can be used to retrieve the login timeout that has been configured.

See Also:
Constant Field Values

GET_LOGIN_TIMEOUT_METHOD_NUMBER

public static final int GET_LOGIN_TIMEOUT_METHOD_NUMBER
The method number for the "getLoginTimeout" method.

See Also:
Constant Field Values

GET_QUERY_TIMEOUT_METHOD_NAME

public static final java.lang.String GET_QUERY_TIMEOUT_METHOD_NAME
The name of the method that can be used to retrieve the query timeout that has been configured.

See Also:
Constant Field Values

GET_QUERY_TIMEOUT_METHOD_NUMBER

public static final int GET_QUERY_TIMEOUT_METHOD_NUMBER
The method number for the "getQueryTimeout" method.

See Also:
Constant Field Values

IS_CONNECTED_METHOD_NAME

public static final java.lang.String IS_CONNECTED_METHOD_NAME
The name of the method that can be used to determine whether this connection is currently established.

See Also:
Constant Field Values

IS_CONNECTED_METHOD_NUMBER

public static final int IS_CONNECTED_METHOD_NUMBER
The method number for the "isConnected" method.

See Also:
Constant Field Values

PREPARE_STATEMENT_METHOD_NAME

public static final java.lang.String PREPARE_STATEMENT_METHOD_NAME
The name of the method that can be used to create a prepared statement.

See Also:
Constant Field Values

PREPARE_STATEMENT_METHOD_NUMBER

public static final int PREPARE_STATEMENT_METHOD_NUMBER
The method number for the "prepareStatement" method.

See Also:
Constant Field Values

ROLL_BACK_METHOD_NAME

public static final java.lang.String ROLL_BACK_METHOD_NAME
The name of the method that can be used to roll back any outstanding changes.

See Also:
Constant Field Values

ROLL_BACK_METHOD_NUMBER

public static final int ROLL_BACK_METHOD_NUMBER
The method number for the "rollBack" method.

See Also:
Constant Field Values

SET_AUTO_COMMIT_METHOD_NAME

public static final java.lang.String SET_AUTO_COMMIT_METHOD_NAME
The name of the method that can be used to enable or disable autocommit in the database.

See Also:
Constant Field Values

SET_AUTO_COMMIT_METHOD_NUMBR

public static final int SET_AUTO_COMMIT_METHOD_NUMBR
The method number for the "setAutoCommit" method.

See Also:
Constant Field Values

SET_DRIVER_CLASS_METHOD_NAME

public static final java.lang.String SET_DRIVER_CLASS_METHOD_NAME
The name of the method that can be used to specify the JDBC driver class to use.

See Also:
Constant Field Values

SET_DRIVER_CLASS_METHOD_NUMBER

public static final int SET_DRIVER_CLASS_METHOD_NUMBER
The method number for the "setDriverClass" method.

See Also:
Constant Field Values

SET_LOGIN_TIMEOUT_METHOD_NAME

public static final java.lang.String SET_LOGIN_TIMEOUT_METHOD_NAME
The name of the method that can be used to specify the login timeout.

See Also:
Constant Field Values

SET_LOGIN_TIMEOUT_METHOD_NUMBER

public static final int SET_LOGIN_TIMEOUT_METHOD_NUMBER
The method number for the "setLoginTimeout" method.

See Also:
Constant Field Values

SET_QUERY_TIMEOUT_METHOD_NAME

public static final java.lang.String SET_QUERY_TIMEOUT_METHOD_NAME
The name of the method that can be used to specify the query timeout.

See Also:
Constant Field Values

SET_QUERY_TIMEOUT_METHOD_NUMBER

public static final int SET_QUERY_TIMEOUT_METHOD_NUMBER
The method number for the "setQueryTimeout" method.

See Also:
Constant Field Values

JDBC_CONNECTION_VARIABLE_METHODS

public static final Method[] JDBC_CONNECTION_VARIABLE_METHODS
The set of methods associated with JDBC connection variables.

Constructor Detail

JDBCConnectionVariable

public JDBCConnectionVariable()
                       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.
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.