com.rocketsoftware.mvapi
Class MVStatement

java.lang.Object
  extended by com.rocketsoftware.mvapi.AbstractStatement
      extended by com.rocketsoftware.mvapi.MVStatement
All Implemented Interfaces:
java.sql.Statement

public class MVStatement
extends AbstractStatement

Provides methods for executing commands and calling subroutines on the server.


Field Summary
 
Fields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
 
Constructor Summary
MVStatement(MVConnection mvConnection)
          Constructs an MVStatement object from a connection object.
MVStatement(MVConnection mvConnection, java.lang.String statement)
          Constructs an MVStatement object from a connection object and statement.
 
Method Summary
 void close()
          Releases this Statement object's database resources immediately.
 boolean execute(java.lang.String TCL)
          Executes a statement on the server.
 MVResultSet executeQuery(java.lang.String TCL)
          Executes a statement on the server.
 MVResultSet executeQuery(java.lang.String filename, java.lang.String selectionCriteria, java.lang.String sortCriteria, java.lang.String ADIList)
          Executes a query with the provided selection and sort criteria, then returns the requested columns.
 MVResultSet executeQuery(java.lang.String filename, java.lang.String selectionCriteria, java.lang.String sortCriteria, java.lang.String[] ADIArray)
          Executes a query with the provided selection and sort criteria, then returns the requested columns.
 MVResultSet executeQuery(java.lang.String filename, java.lang.String selectionCriteria, java.lang.String sortCriteria, java.lang.String[] ADIArray, java.lang.String[] ItemIdArray)
          Executes a query with the provided selection and sort criteria, then returns the requested columns.
 MVResultSet executeQuery(java.lang.String filename, java.lang.String selectionCriteria, java.lang.String sortCriteria, java.lang.String[] ADIArray, java.lang.String[] ItemIdArray, java.lang.String queryKeywords)
          Executes a query with the provided selection and sort criteria, then returns the requested columns.
 MVResultSet executeQuery(java.lang.String filename, java.lang.String selectionCriteria, java.lang.String sortCriteria, java.lang.String ADIList, java.lang.String ItemIdList)
          Executes a query with the provided selection and sort criteria, then returns the requested columns.
 MVResultSet executeQuery(java.lang.String filename, java.lang.String selectionCriteria, java.lang.String sortCriteria, java.lang.String ADIList, java.lang.String ItemIdList, java.lang.String queryKeywords)
          Executes a query with the provided selection and sort criteria, then returns the requested columns.
 MVConnection getConnection()
          Return the connection object.
 MVResultSet getResultSet()
          Retrieves the result as a ResultSet object.
 
Methods inherited from class com.rocketsoftware.mvapi.AbstractStatement
addBatch, cancel, clearBatch, clearWarnings, execute, execute, execute, executeBatch, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MVStatement

public MVStatement(MVConnection mvConnection)
Constructs an MVStatement object from a connection object.

Parameters:
mvConnection - a connection to an MV server

MVStatement

public MVStatement(MVConnection mvConnection,
                   java.lang.String statement)
Constructs an MVStatement object from a connection object and statement.

Parameters:
mvConnection - the connection to the MV server
statement - an AQL query, TCL verb or Subroutine.
Method Detail

executeQuery

public MVResultSet executeQuery(java.lang.String TCL)
                         throws MVException
Executes a statement on the server.

Specified by:
executeQuery in interface java.sql.Statement
Overrides:
executeQuery in class AbstractStatement
Parameters:
TCL - query string:

if the TCL string contains an attribute mark delimiter, the TCL string is interpreted as a subroutine call otherwise the TCL string is interpreted as a TCL command line statement.

For subroutine calls, the TCL string is an attribute mark delimited string, where the first attribute is the subroutine name. The remaining attributes are passed to the subroutine as a dynamic array for the subroutine's first argument, indata. The subroutine must return data through it's second argument, outdata. The outdata is used to populate the ResultSet. Each attribute in the outdata argument generates one row in the generated ResultSet.

The subroutine must be defined to accept two arguments:

subname(indata, outdata)

Returns:
ResultSet contains the data returned from subroutine's outdata parameter
Throws:
MVException - raised if any errors occur

executeQuery

public MVResultSet executeQuery(java.lang.String filename,
                                java.lang.String selectionCriteria,
                                java.lang.String sortCriteria,
                                java.lang.String ADIList,
                                java.lang.String ItemIdList,
                                java.lang.String queryKeywords)
                         throws MVException
Executes a query with the provided selection and sort criteria, then returns the requested columns.

Parameters:
filename - The filename to query

selectionCriteria - selection criteria in the native retrieval language syntax

for example: WITH ORDERDATE >= "07/01/09" AND WITH EMPLOYEEID = "10"

sortCriteria - sort criteria in the native retrieval language syntax

for example BY ORDERDATE BY CUSTOMERID

ADIList - Attribute defining items to populate the result set

for example ORDERDATE CUSTOMERID EMPLOYEEID PRODUCTID QUANTITY UNITPRICE

ItemIdList - list of item-Ids to retrieve seperated by spaces.

for example 100 200 300

queryKeywords - list of AQL keywords delimited by value marks

Currently only the AQL USING keyword is recognized in this parameter to allow using an alternate file dictionary, for example USING DICT ORDERS.DICT

Each row in the resultset will contain an attribute mark delimited string representing the returned item. To retrieve individual columns, use the getString(columnNumber) with columnNumber corresponding to an ADI in the ADIList parameter.

For example getString(4) will return the PRODUCTID.

If the column attribute contains multivalues or subvalues, they can be extracted using the MVString class, for example:

String productID = resultSet.getString(4); String value = MVString.extract(1, 2); // get the second value

Returns:
MVResultSet ResultSet containing the result of this query.
Throws:
MVException - raised if any errors occur

executeQuery

public MVResultSet executeQuery(java.lang.String filename,
                                java.lang.String selectionCriteria,
                                java.lang.String sortCriteria,
                                java.lang.String ADIList,
                                java.lang.String ItemIdList)
                         throws MVException
Executes a query with the provided selection and sort criteria, then returns the requested columns.

Parameters:
filename - The filename to query

selectionCriteria - selection criteria in the native retrieval language syntax

for example: WITH ORDERDATE >= "07/01/09" AND WITH EMPLOYEEID = "10"

sortCriteria - sort criteria in the native retrieval language syntax

for example BY ORDERDATE BY CUSTOMERID

ADIList - Attribute defining items to populate the result set

for example ORDERDATE CUSTOMERID EMPLOYEEID PRODUCTID QUANTITY UNITPRICE

ItemIdList - list of item-Ids to retrieve seperated by spaces.

for example 100 200 300

Each row in the resultset will contain an attribute mark delimited string representing the returned item. To retrieve individual columns, use the getString(columnNumber) with columnNumber corresponding to an ADI in the ADIList parameter.

For example getString(4) will return the PRODUCTID.

If the column attribute contains multivalues or subvalues, they can be extracted using the MVString class, for example:

String productID = resultSet.getString(4); String value = MVString.extract(1, 2); // get the second value

Returns:
MVResultSet ResultSet containing the result of this query.
Throws:
MVException - raised if any errors occur

executeQuery

public MVResultSet executeQuery(java.lang.String filename,
                                java.lang.String selectionCriteria,
                                java.lang.String sortCriteria,
                                java.lang.String ADIList)
                         throws MVException
Executes a query with the provided selection and sort criteria, then returns the requested columns.

Parameters:
filename - The filename to query

selectionCriteria - selection criteria in the native retrieval language syntax

for example: WITH ORDERDATE >= "07/01/09" AND WITH EMPLOYEEID = "10"

sortCriteria - sort criteria in the native retrieval language syntax

for example BY ORDERDATE BY CUSTOMERID

ADIList - Attribute defining items to populate the result set

for example ORDERDATE CUSTOMERID EMPLOYEEID PRODUCTID QUANTITY UNITPRICE

Each row in the resultset will contain an attribute mark delimited string representing the returned item. To retrieve individual columns, use the getString(columnNumber) with columnNumber corresponding to an ADI in the ADIList parameter.

For example getString(4) will return the PRODUCTID.

If the column attribute contains multivalues or subvalues, they can be extracted using the MVString class, for example:

String productID = resultSet.getString(4); String value = MVString.extract(1, 2); // get the second value

Returns:
MVResultSet ResultSet containing the result of this query.
Throws:
MVException - raised if any errors occur

executeQuery

public MVResultSet executeQuery(java.lang.String filename,
                                java.lang.String selectionCriteria,
                                java.lang.String sortCriteria,
                                java.lang.String[] ADIArray)
                         throws MVException
Executes a query with the provided selection and sort criteria, then returns the requested columns.

Parameters:
filename - The filename to query

selectionCriteria - selection criteria in the native retrieval language syntax

for example: WITH ORDERDATE >= "07/01/09" AND WITH EMPLOYEEID = "10"

sortCriteria - sort criteria in the native retrieval language syntax

for example BY ORDERDATE BY CUSTOMERID

ADIArray - an array of attribute defining items to populate the result set

for example ORDERDATE CUSTOMERID EMPLOYEEID PRODUCTID QUANTITY UNITPRICE

Each row in the resultset will contain an attribute mark delimited string representing the returned item. To retrieve individual columns, use the getString(columnNumber) with columnNumber corresponding to an ADI in the ADIArray parameter.

For example getString(4) will return the PRODUCTID.

If the column attribute contains multivalues or subvalues, they can be extracted using the MVString class, for example:

String productID = resultSet.getString(4); String value = MVString.extract(1, 2); // get the second value

Returns:
MVResultSet ResultSet containing the result of this query.
Throws:
MVException - raised if any errors occur

executeQuery

public MVResultSet executeQuery(java.lang.String filename,
                                java.lang.String selectionCriteria,
                                java.lang.String sortCriteria,
                                java.lang.String[] ADIArray,
                                java.lang.String[] ItemIdArray,
                                java.lang.String queryKeywords)
                         throws MVException
Executes a query with the provided selection and sort criteria, then returns the requested columns.

Parameters:
filename - The filename to query

selectionCriteria - selection criteria in the native retrieval language syntax

for example: WITH ORDERDATE >= "07/01/09" AND WITH EMPLOYEEID = "10"

sortCriteria - sort criteria in the native retrieval language syntax

for example BY ORDERDATE BY CUSTOMERID

ADIArray - an array of attribute defining items to populate the result set

for example ORDERDATE CUSTOMERID EMPLOYEEID PRODUCTID QUANTITY UNITPRICE

ItemIdArray - an array of item-Ids to retrieve seperated by spaces.

for example 100 200 300

queryKeywords - list of AQL keywords delimited by value marks

Currently only the AQL USING keyword is recognized in this parameter to allow using an alternate file dictionary, for example USING DICT ORDERS.DICT

Each row in the resultset will contain an attribute mark delimited string representing the returned item. To retrieve individual columns, use the getString(columnNumber) with columnNumber corresponding to an ADI in the ADIArray parameter.

For example getString(4) will return the PRODUCTID.

If the column attribute contains multivalues or subvalues, they can be extracted using the MVString class, for example:

String productID = resultSet.getString(4); String value = MVString.extract(1, 2); // get the second value

Returns:
MVResultSet ResultSet containing the result of this query.
Throws:
MVException - raised if any errors occur

executeQuery

public MVResultSet executeQuery(java.lang.String filename,
                                java.lang.String selectionCriteria,
                                java.lang.String sortCriteria,
                                java.lang.String[] ADIArray,
                                java.lang.String[] ItemIdArray)
                         throws MVException
Executes a query with the provided selection and sort criteria, then returns the requested columns.

Parameters:
filename - The filename to query

selectionCriteria - selection criteria in the native retrieval language syntax

for example: WITH ORDERDATE >= "07/01/09" AND WITH EMPLOYEEID = "10"

sortCriteria - sort criteria in the native retrieval language syntax

for example BY ORDERDATE BY CUSTOMERID

ADIArray - an array of attribute defining items to populate the result set

for example ORDERDATE CUSTOMERID EMPLOYEEID PRODUCTID QUANTITY UNITPRICE

ItemIdArray - an array of item-Ids to retrieve seperated by spaces.

for example 100 200 300

Each row in the resultset will contain an attribute mark delimited string representing the returned item. To retrieve individual columns, use the getString(columnNumber) with columnNumber corresponding to an ADI in the ADIArray parameter.

For example getString(4) will return the PRODUCTID.

If the column attribute contains multivalues or subvalues, they can be extracted using the MVString class, for example:

String productID = resultSet.getString(4); String value = MVString.extract(1, 2); // get the second value

Returns:
MVResultSet ResultSet containing the result of this query.
Throws:
MVException - raised if any errors occur

close

public void close()
           throws MVException
Releases this Statement object's database resources immediately.

Calling the method close on a Statement object that is already closed has no effect.

Specified by:
close in interface java.sql.Statement
Overrides:
close in class AbstractStatement
Throws:
MVException - if a database access error occurs

execute

public boolean execute(java.lang.String TCL)
                throws MVException
Executes a statement on the server.

Specified by:
execute in interface java.sql.Statement
Overrides:
execute in class AbstractStatement
Parameters:
TCL - query string:

if the TCL string contains an attribute mark delimiter, the TCL string is interpreted as a subroutine call otherwise the TCL string is interpreted as a TCL command line statement.

For subroutine calls, the TCL string is an attribute mark delimited string, where the first attribute is the subroutine name. The remaining attributes are passed to the subroutine as a dynamic array for the subroutine's first argument, indata. The subroutine must return data through it's second argument, outdata. The outdata is used to populate the ResultSet. Each attribute in the outdata argument generates one row in the generated ResultSet.

The subroutine must be defined to accept two arguments:

subname(indata, outdata)

Returns:
ResultSet contains the data returned from subroutine's outdata parameter
Throws:
MVException - raised if any errors occur

getResultSet

public MVResultSet getResultSet()
                         throws MVException
Retrieves the result as a ResultSet object.

Specified by:
getResultSet in interface java.sql.Statement
Overrides:
getResultSet in class AbstractStatement
Returns:
the current result as a ResultSet object
Throws:
MVException - if a database access error occurs
See Also:
execute(java.lang.String)

getConnection

public MVConnection getConnection()
Return the connection object.

Specified by:
getConnection in interface java.sql.Statement
Overrides:
getConnection in class AbstractStatement
Returns:
MVConnection object