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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.