Setting properties in the query dialog

Database application development is a feature of JBuilder Professional and Enterprise. Distributed application development is a feature of JBuilder Enterprise.

The Query property editor displays when you click the ellipsis button in the value field for the query property of a QueryDataSet. You can use the Query property editor to set the properties of the QueryDescriptor visually, but it also has several other uses. The Query property editor is shown below. Each of its options is explained in further detail as well.

For more information, see the com.borland.dx.sql.dataset.QueryDescriptor topic in the DataExpress Library Reference documentation.

The Query page

On the Query tab, the following options are available:

The Parameters page

On the Parameters tab, you can select an optional ReadWriteRow or DataSet from which to fill in parameters, used for parameterized queries. Parameter values are specified through an instantiated ReadWriteRow. Select the ReadWriteRow object (or the ReadWriteRow subclass) that contains the values for your query parameters from the drop-down list.

Parameters page of QueryDescriptor

Any ReadWriteRow, such as ParameterRow, DataSet, and DataRow may be used as query or procedure parameters. In a ParameterRow, columns can simply be set up with the addColumns and setColumns methods. DataSet and DataRow should only be used if they already contain the columns with the wanted data. See "Using parameterized queries to obtain data from your database" for an example of this.

Place SQL text in resource bundle

A java.util.ResourceBundle contains locale-specific objects. When your program needs a locale-specific resource, your program can load it from the resource bundle that is appropriate for the current user's locale. In this way, you can write program code that is largely independent of the user's locale isolating most, if not all, of the locale-specific information in resource bundles.

The Create ResourceBundle dialog appears when the query editor is closing, if a SQL statement has been defined in the query editor and the "Place SQL Text In Resource Bundle" option has been checked. The resource bundle dialog looks like this:

To use a resource bundle in your application,

  1. Select a type of ResourceBundle. To simplify things, the JDK provides two useful subclasses of ResourceBundle: ListResourceBundle and PropertyResourceBundle. The ResourceBundle class is itself an abstract class. In order to create a concrete bundle, you need to derive from ResourceBundle and provide concrete implementations of some functions which retrieve from whatever storage you put your resources in, such as string. You can store resources into this bundle by right-clicking a property and specifying the key. JBuilder will write the strings into the resource file in the right format depending on the type.
  2. Click Cancel or OK:

    Clicking the Cancel button (or deselecting the "Place SQL text in resource bundle" option in the query dialog), writes a QueryDescriptor like the following to the Frame file. The SQL text is written as a string embedded in the source code.

    queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1,
        "select * from employee", null, true, LOAD.ALL));

    Clicking the OK button creates a queryDescriptor like the following:

    queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1,
        sqlRes.getString("employee"), null, true, LOAD.ALL));
    

    Whenever you save the SQL text in the QueryDescriptor dialog, JBuilder automatically creates a new file called "SqlRes.java". It places the text for the SQL string inside SqlRes.java and creates a unique string "tag" which it inserts into the text. For example, for the select statement "SELECT * FROM employee", as entered above, the moment the OK is pressed, the file SqlRes.java would be created, looking something like this:

    public class SqlRes extends java.util.ListResourceBundle {
      static final Object[][] contents = {
    	{ "employee", "select * from employee" }};
      static final java.util.ResourceBundle res = getBundle("untitled3.SqlRes");
      public static final String getStringResource(String key) {
        return res.getString(key);
      }
      public Object[][] getContents() {
        return contents;
      }
    } 
    

    If the SQL statement is changed, the changes are saved into SqlRes.java. No changes will be necessary to the code inside jbInit(), because the "tag" string is invariant.

For more information on resource bundles, see the JavaDoc for java.util.ResourceBundle, found from JBuilder help by selecting Help|Java Reference. Then select the java.util package, and the ResourceBundle class.