Java API

Synopsis

public QueryResultSet

query(PreparedStatement query,

java.lang.String[] selectKeys,

int resultsPerFetch)

Description

Takes a where clause and a select clause and returns a QueryResultSet of NameValueRecord instances containing the selected values.

selectKeys identifies the values to be returned, functioning as an SQL select clause.

The PreparedStatement parameter enables queries with dynamic parameters to pass typed data items to the query.

Returns a QueryResultSet. The results are stepped through by calling the next method and using the getObjectIdentifier accessor.

Note – For more information on the 5800 system query language, refer to Chapter 4, “Sun StorageTek 5800 System Query Language.”

PreparedStatement

Extends com.sun.honeycomb.common.Encoding

Synopsis

public PreparedStatement(java.lang.String sql);

Description

Used to implement queries with Dynamic Parameters, which is the preferred way to pass typed data items to a StorageTek 5800 query.

The number of bindParameter calls should match the number of question marks (?) in the query string in the prepared statement. Parameters are specified positionally. For example, a bindParameter call with index = 1 supplies a value for the first? in the supplied query string. Once a value has been supplied for each of the dynamic parameters, then the PreparedStatement may be passed to the NameValueObjectArchive.query method to be executed, for example:

NameValueObjectArchive archive = new NameValueObjectArchive(hostname);

Date date_value= new java.sql.Date();

PreparedStatement stmt = new PreparedStatement("date_field<?”);

36

Sun StorageTek 5800 System Client API Reference Manual • June 2008

Page 36
Image 36
Sun Microsystems 5800 manual PreparedStatement