Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
490
Chapter 18 JDBC and Database Connection Pooling
Figure 18 5 Query viewer after a request for part of the fruits table from a Sybase
database.
quick summary of the process that takes place when the user presses the
Show Results button.
First, the system reads the host, port, database name, username, password,
and driver type from the user interface elements shown. Next, it submits the
query and stores the result, as below:
DBResults results =
DatabaseUtilities.getQueryResults(driver, url,
username, password,
query, true);
Next, the system passes these results to a custom table model (see Listing
18.15). If you are not familiar with the Swing GUI library, a table model
acts as the glue between a
JTable
and the actual data.
DBResultsTableModel model = new DBResultsTableModel(results);
JTable table = new JTable(model);
Finally, the system places this
JTable
in the bottom region of the
JFrame
and calls
pack
to tell the
JFrame
to resize itself to fit the table.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved