To access relational data using a Select bean, you connect an interface component to the Select bean. For example, you can make an event-to-method connection between the actionPerformed event for a button and the execute method of the Select bean. When the button is selected, the SQL statement associated with the Select bean is executed.
Alternatively, you can connect the DBNavigator bean to the Select bean. The DBNavigator
bean provides a set of buttons that includes an Execute button . The
DBNavigator bean is a Swing component, and requires the Java Foundation Classes (JFC)
library. To use the DBNavigator bean, you create a property-to-property connection between
the this property of the Select bean and the model property of the DBNavigator bean. The
this property refers to the whole object of the Select bean. The model property specifies
which Select or ProcedureCall bean the DBNavigator bean will navigate. When selected, the
Execute button in the DBNavigator bean invokes the execute method of the Select bean,
which executes the SQL statement.
If you have defined parameters in your SQL statement, you must set the parameters before you invoke the execute method. If you used the SQL Assist SmartGuide to compose the SQL statement, VisualAge for Java generates two bound properties for each parameter you defined. One property is the parameter in its specified data type. The other property is a String representation of the parameter. So, for example, you can make a property-to-property connection between the text property of a text field and the String representation of a parameter. Because the text property is not bound, you must also specify in the connection properties an event to trigger the propagation of the text value to the parameter. Once you do this, code is generated to invoke the setParameterFromString method whenever the event is fired.
When you execute an SQL statement using a Select bean, it returns a result set. Unlike the native Java interface to relational data (JDBC), the Select bean maintains rows of the result set in a memory cache where you can move back and forth among the rows. The number of rows initially fetched when you execute is controlled by the following properties of the Select bean:
If fillCacheOnExecute is set to false, one packet of rows is initially fetched. If fillCacheOnExecute is set to true, the number of rows fetched is the least of: all of the rows, the limit imposed by the maximumRows property, the limit imposed by packetSize times maximumPacketsInCache. (If you use the default values for all of these properties, all of the rows are fetched.)
If there are any rows in the result set, regardless of how many rows were initially fetched, you are positioned on the first one.
About Relational Database Access
Editing Select bean properties
Adding the DBNavigator bean to the Visual Composition
Editor surface
Connecting beans
Data Access Beans