Java Reference
In-Depth Information
The value of the specifi ed property will be displayed at the position in the Web
page where this tag occurs. Note that a named property X does not actually have
to exist as an attribute of the bean, but method getX must. This can be very useful
for returning a calculated value, as the example below illustrates.
This example simply extends by providing method getNumAc-
counts , which returns the number of account holders in table Accounts of our
Finances database. The new version of the bean is called JDBCBean X .java . For
ease of comparison with the original bean, the code changes are shown in bold.
package jdbc;
import java.sql.*;
import java.util.*;
public class JDBCBeanX
private static Connection link;
private static Statement statement;
private static ResultSet results;
private static Vector<Object> acctDetails;
private fi nal int NUM_FIELDS = 3;
public JDBCBeanX() throws SQLException,
connection = DriverManager.getConnection(
statement = connection.createStatement();
results = statement.executeQuery(
"SELECT * FROM Accounts");
acctDetails = new Vector<Object>();
while (
+ " " + results.getString(2));
public Vector<Object> getAcctDetails()
Search WWH ::

Custom Search