22.3. Some JDBC Utilities

In many applications, you don't need to process query results a row at a time. For example, in servlets and JSP pages, it is common to simply format the database results (treating all values as strings) and present them to the user in an HTML table, in an Excel spreadsheet, or distributed throughout the page. In such a case, it simplifies processing to have methods that retrieve and store an entire ResultSet for later display.

This section presents two classes that provide this basic functionality along with a few formatting, display, and table creation utilities. The core class is DatabaseUtilities, which implements static methods for four common tasks:

  1. getQueryResults This method connects to a database, executes a ...

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.