borland.jbcl Packages  borland.jbcl Class Hierarchy  borland.jbcl.dataset 

QueryDescriptor class

java.lang.Object
   +----borland.jbcl.dataset.QueryDescriptor
           +----borland.jbcl.dataset.ProcedureDescriptor

About the QueryDescriptor class

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

To work with this component programatically, you set its properties when instantiating the QueryDescriptor object, or individually by its write accessor methods. For properties that do not have corresponding setter methods, use a constructor that takes that property as a parameter. If your query requires parameters, these can be set programatically -- for more information and an example on how to do this, see Using parameterized queries to obtain data from your database in the Database Application Developer's Guide.

Through the user-interface, the information stored in the QueryDescriptor can be accessed by inspecting the query property of a QueryDataSet object. This displays the query custom property editor. The query property editor also provides additional functionality of table discovery through the Browse Tables button. Clicking this button displays a dialog listing available tables in the database (as specified by the connectionURL property). When you select a table from this dialog, its columns are listed as well. Buttons allow you to easily paste the table or column name into the query string to create the query statement to run against the server database.

When you close the query property editor, as long as the necessary properties have been specified (the query statement and Database object), JBuilder runs the query against the specified Database object.

You can also explicitly test the query properties by clicking the Test query button from within the Query property editor.

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 udpates to the row count.

As an asynchronous query fetches rows of data, they are appended to the end of the DataSet. If 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.

For examples on using a QueryDataSet and its associated QueryDescriptor, see Querying a database in the Database Application Developer's Guide.

Note: 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(borland.jbcl.dataset.Database, java.lang.String)

  public QueryDescriptor(borland.jbcl.dataset.Database database, java.lang.String query)

QueryDescriptor(borland.jbcl.dataset.Database, java.lang.String, boolean)

  public QueryDescriptor(borland.jbcl.dataset.Database database, java.lang.String query, boolean executeOnOpen)

QueryDescriptor(borland.jbcl.dataset.Database, java.lang.String, borland.jbcl.dataset.ParameterRow)

  public QueryDescriptor(borland.jbcl.dataset.Database database, java.lang.String query, borland.jbcl.dataset.ParameterRow parameters)

QueryDescriptor(borland.jbcl.dataset.Database, java.lang.String, borland.jbcl.dataset.ParameterRow, boolean)

  public QueryDescriptor(borland.jbcl.dataset.Database database, java.lang.String query, borland.jbcl.dataset.ParameterRow parameters, boolean executeOnOpen)

QueryDescriptor(borland.jbcl.dataset.Database, java.lang.String, borland.jbcl.dataset.ParameterRow, boolean, boolean)

  public QueryDescriptor(borland.jbcl.dataset.Database database, java.lang.String query, borland.jbcl.dataset.ParameterRow parameters, boolean executeOnOpen, boolean asynchronousExecution)

QueryDescriptor properties

asynchronousExecution

 public final boolean isAsynchronousExecution()
 public final void setAsynchronousExecution(boolean async)
Stores whether a new thread should be created for executing the query and fetching the results (true) or whether the query should be run in the current thread (false). Setting this property to true can yield better performance. However, running the query in a separate thread could introduce the possibility of dead-lock. This option defaults to false (non-checked in the UI) which means that the query runs in the current thread.

database

 public Database getDatabase()
Read-only property that returns the instantiated Database that the query is associated with.

executeOnOpen

 public boolean isExecuteOnOpen()
 public void setExecuteOnOpen(boolean executeOnOpen)
Property that specifies whether the query is executed automatically when the QueryDataSet is opened. When true (the default value), the query is executed automatically and allows for live data to display in UI controls (such as the GridControl) in the JBuilder UI Designer. To prevent the query from automatically executing when the QueryDataSet is opened, set this property to false.

parameterRow

 public ParameterRow getParameterRow()
The ParameterRow property of the QueryDescriptor is mutable. A call to QueryDataSet.changeParameters will change the QueryDescriptor's ParameterRow property.

queryString

 public String getQueryString()
The query string to run against the Database.

QueryDescriptor methods

toString()

  public String toString()
Returns a String equivalent of the property values stored in the QueryDescriptor. This String representation appears in the JBuilder Component Inspector as the value of the query property.

Overrides: java.lang.Object.toString()