22.5. An Interactive Query Viewer

Up to this point, all the database results have been based upon queries that were known at the time the program was written. In many real applications, however, queries are derived from user input that is not known until run time. Sometimes the queries follow a fixed format even though certain values change. You should make use of prepared statements in such a case; see Section 22.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 22.1 (Basic Steps in Using JDBC). In fact, the database utilities of Listing 22.6 ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.