Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
488
Chapter 18 JDBC and Database Connection Pooling
Sometimes the queries follow a fixed format even though certain values
change. You should make use of prepared statements in such a case; see Sec
tion 18.6 for details. Other times, however, even the query format is variable.
Fortunately, this situation presents no problem, since
ResultSetMetaData
can be used to determine the number, names, and types of columns in a
ResultSet
, as was discussed in Section 18.1 (Basic Steps in Using JDBC). In
fact, the database utilities of Listing 18.6 store that metadata in the
DBResults
object that is returned from the
showQueryData
method. Access
to this metadata makes it straightforward to implement an interactive graphi
cal query viewer as shown in Figures 18 1 through 18 5. The code to accom
plish this result is presented in the following subsection.
Figure 18 1 Initial appearance of the query viewer.
Figure 18 2 Query viewer after a request for the complete employees table from an
Oracle database.
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