Executing a Select Bean

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.

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. When you make the connection, code is generated to invoke the setParameterFromString method; the method sets the parameter value.

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 that the DBNavigator bean will navigate the associated Select bean. When selected, the Execute button in the DBNavigator bean invokes the execute method of the Select bean, which executes the SQL statement.

When you execute an SQL statement using a Select bean, it returns a result set. However the actual number of rows fetched into memory (cache) is controlled by various properties of the Select bean. You can set the value of these properties and thus control how many rows are fetched. The properties determine:


Related concepts
About Relational Database Access

Related procedures
Editing Select Bean Properties
Adding the DBNavigator Bean to the Visual Composition Editor Surface
Connecting Beans

Related references
Data Access Beans