18.4. Applying the Database Utilities
Now, let's see how the database utilities of Section 18.3 can simplify the retrieval and display of database results. Listing 18.8 presents a class that connects to the database specified on the command line and prints out all entries in the employees table. Listings 18.9 and 18.10 show the results when connecting to Oracle and Sybase databases, respectively. Listing 18.11 shows a similar class that performs the same database lookup but formats the results in an HTML table. Listing 18.12 shows the raw HTML result. I'll put an HTML table like this in a real Web page in Section 18.8 (Connection Pooling: A Case Study).
Listing 18.13 shows the JDBC code used to create the employees table.
Listing 18.8. EmployeeTest.java ...
Get Core Servlets and JavaServer Pages™ 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.