borland Packages  Class Hierarchy  dx.sql.dataset Package 

QueryDescriptor class

java.lang.Object
   +----com.borland.dx.sql.dataset.QueryDescriptor
           +----com.borland.dx.sql.dataset.ProcedureDescriptor

About the QueryDescriptor class

Constructors  Properties  Methods  

Implements Serializable

The QueryDescriptor stores properties that set a query statement to run against a SQL database. To access SQL table data using a QueryDataSet, the Database component and QueryDescriptor object are also required. The properties of the QueryDescriptor object are:

To work with this component programmatically, you set its properties when instantiating the QueryDescriptor object, or individually by its write accessor methods. For properties that do not have a corresponding setter method, use a constructor that takes that property as a parameter.

Loading data

Data can be loaded all in one fetch, as needed, asynchronously or one at a time (as specified by the loadOption property). When working with asynchronous queries, opening the QueryDataSet then immediately calling methods such as rowCount() typically returns a row count lower than expected. To avoid this, either set the query to synchronous, listen for the LoadingEvent, perform other actions while the QueryDataSet completes loading, or listen for updates to the row count.

As an asynchronous query fetches rows of data, they are appended to the end of the DataSet. When working with a sorted view of the DataSet, the new rows appear in the specified sort order. Also, be careful to not make assumptions about the current row position since rows are inserted into the sorted view as they are fetched, thereby changing row positions automatically.

Executing queries

When executing queries, you have several options from which to choose, depending on your query statement. If your statement returns a ResultSet, use a QueryDataSet component with a QueryDescriptor. For example, the statement

     select * from customer
If you also require the addition of parameter passing (all named or all unnamed), assign these values to an object derived from ReadWriteRow (for example, a ParameterRow) in conjunction with the QueryDataSet.

Do not use a QueryDataSet if your SQL statement doesn't yield a ResultSet. Instead, use one of the following:

Oracle synonyms

If a query is run against a synonym on an Oracle server, it is dependent on the support of synonyms in the JDBC driver to determine whether the query is updatable.


QueryDescriptor constructors

QueryDescriptor properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in java.lang.Object

QueryDescriptor methods

Methods implemented in this class

Methods implemented in java.lang.Object


QueryDescriptor constructors

QueryDescriptor(com.borland.dx.sql.dataset.Database, java.lang.String)

  public QueryDescriptor(Database database, String query)
Constructs a QueryDescriptor object with the following properties:

Parameters:

database
The Database object the QueryDataSet is to run against.
query
The query string to execute against the specified database.

QueryDescriptor(com.borland.dx.sql.dataset.Database, java.lang.String, boolean)

  public QueryDescriptor(Database database, String query, boolean executeOnOpen)
Constructs a QueryDescriptor object with the following properties:

Parameters:

database
The Database object the QueryDataSet is to run against.
query
The query string to execute against the specified database.
executeOnOpen
Whether or not the query should execute immediately when an object that is bound to the QueryDataSet is opened.

QueryDescriptor(com.borland.dx.sql.dataset.Database, java.lang.String, com.borland.dx.dataset.ReadWriteRow)

  public QueryDescriptor(Database database, String query, ReadWriteRow parameters)
Constructs a QueryDescriptor object with the following properties:

Parameters:

database
The Database object the QueryDataSet is to run against.
query
The query string to execute against the specified database.
parameters
The ReadWriteRow implementation that contains the values to use for the parameters of the query string.

QueryDescriptor(com.borland.dx.sql.dataset.Database, java.lang.String, com.borland.dx.dataset.ReadWriteRow, boolean)

  public QueryDescriptor(Database database, String query, ReadWriteRow parameters, boolean executeOnOpen)
Constructs a QueryDescriptor object with the following properties:

Parameters:

database
The Database object the QueryDataSet is to run against.
query
The query string to execute against the specified database.
parameters
The ReadWriteRow implementation that contains the values to use for the parameters of the query string.
executeOnOpen
Whether or not the query should execute immediately when an object that is bound to the QueryDataSet is opened.

QueryDescriptor(com.borland.dx.sql.dataset.Database, java.lang.String, com.borland.dx.dataset.ReadWriteRow, boolean, boolean)

  public QueryDescriptor(Database database, String query, ReadWriteRow parameters, boolean executeOnOpen, boolean asynchronousExecution)
This constructor has been deprecated. Use a constructor that takes a loadOption parameter, or set the loadOption property directly.

QueryDescriptor(com.borland.dx.sql.dataset.Database, java.lang.String, com.borland.dx.dataset.ReadWriteRow, boolean, int)

  public QueryDescriptor(Database database, String query, ReadWriteRow parameters, boolean executeOnOpen, int loadOption)
Constructs a QueryDescriptor object with the following properties:

Parameters:

database
The Database object the QueryDataSet is to run against.
query
The query string to execute against the specified database.
parameters
The ReadWriteRow implementation that contains the values to use for the parameters of the query string.
executeOnOpen
Whether or not the query should execute immediately when an object that is bound to the QueryDataSet is opened.
loadOption
How the data should be loaded into the QueryDataSet. Constants for this parameter are defined as Load variables.

QueryDescriptor properties

asynchronousExecution

 public final boolean isAsynchronousExecution()
 public final void setAsynchronousExecution(boolean async)
This property has been deprecated. Use a constructor that takes a loadOption parameter, or set the loadOption property directly.

database

 public Database getDatabase()

Read-only property that returns the instantiated Database that the query is associated with.

To set this property, use any QueryDescriptor constructor that takes this property as a parameter.

executeOnOpen

 public boolean isExecuteOnOpen()
 public void setExecuteOnOpen(boolean executeOnOpen)

If the QueryDataSet is empty, this property specifies whether the query is executed automatically when the QueryDataSet is opened. ("Empty" refers to a DataSet not having any visible or non-visible rows.) When true (the default value), the query is executed automatically and allows for live data to display in UI controls. To prevent the query from automatically executing when the QueryDataSet is opened, set this property to false.

This property does not apply to the ProcedureDescriptor subclass of the QueryDescriptor when used with a ProcedureResolver component.

loadOption

 public final int getLoadOption()
 public final void setLoadOption(int loadOption)
Returns the options specified for loading the QueryDataSet with data. Valid values for this property are defined in Load variables.

parameterRow

 public ReadWriteRow getParameterRow()
Specifies the ReadWriteRow implementation that stores the parameters for the query statement.

queryString

 public String getQueryString()
Read-only property that returns the query string to run against the Database.

To set this property, use any QueryDescriptor constructor that takes this property as a parameter.


QueryDescriptor methods

toString()

  public String toString()
Returns a String equivalent of the property values stored in the QueryDescriptor.

Overrides: java.lang.Object.toString()