Client-Side Presentation Logic
615
JDBC Access: SqlBean and QueryBean Classes
The final source files we will look at are the com.wrox.pjxml.sqlBean class and the
com.wrox.pjxml.queryBean class. These are simple JDBC access beans - sqlBean handles the
connection and disconnection to the JDBC datasource. We're using a simple JDBC to ODBC bridge for
our example. We have named the database "travel"; it contains the following data:
tripno
region
startdate
duration
location
price
commission
31
2
April 15
1 week
Moon Palace in
Cancun
1899
400
32
1
June 19
2 weeks
Princeville Hotel
in Kauai
2699
700
33
3
Jan 16
1 week
Calinda in Aruba
1299
300
34
2
May 12
1 week
Westin Regina in
Puerto Vallarta
1399
300
35
1
Sept 12
1 week
Marriott Kauai
2200
600
36
3
Feb 12
1 week
Pelican Resort in
St. Martin
1700
400
We simply enter this into a table named "hotdeals" and add the database as an ODBC source. The file is
available in the code download as traveldeals.mdb. To add a DSN entry in Windows, select the
Start | Settings | Control Panel and choose the Data Sources (ODBC) entry, which may be in the
Administrative Tools menu. Choose the System DSN tab and select the Add... button. Choose
Microsoft Access Driver (.mdb) as the driver and select Finish.
You will be presented with the following: