Working with relational data: the Select bean
VisualAge for Java supports access to relational databases through JDBC. You can access
relational data in an applet or application by using the Data Access beans on the Visual
Composition Editor beans palette. (Before you can use the Data Access beans, you must
first use the Quick Start window to add the Data Access beans feature to Visual Age for
Java, and you must change the classpath. For more information on accessing relational
data, refer to the online help.)
The Data Access beans comprise a Select bean and a DBNavigator bean. The Select bean
gives you a fast, easy to use, visual programming way of accessing relational data in your
applet or application.
To access relational data using the Select bean:
- Add the Select bean to the Visual Composition Editor surface.
- Edit the Select bean properties. The query property allows you to define the following
things:
- Connection alias. This identifies the characteristics of the database connection
for the Select bean. These include characteristics such as the URL for the connection, and
the user ID and password to be passed with the connection request.
- SQL specification. This specifies the SQL statement for the Select bean. You can
use the SQL editor that is provided to enter the SQL statement manually, or you can use
the SQL Assist SmartGuide to compose the SQL statement visually. You can select one or
more tables, join tables, specify search conditions, identify columns for display, sort
the results, map the data types of the result columns into Java classes, and view the
resulting SQL statement. You can even do a test run of the query.

- Connect the Select bean to a visual component of your applet or application, such as a
button bean. When a user uses the application or applet, and selects the visual component,
for example clicks the button, the SQL statement for the Select bean retrieves a result
set.
You can also use the Select bean to apply changes that users make to a result row, even
deletion of a row, and commit the changes to the database. In these cases, you use update
and delete methods provided by the Select bean.
