22.4. Applying the Database Utilities

Now, let's see how the database utilities of Section 22.3 can simplify the retrieval and display of database results. Listing 22.8 presents a class that connects to the database specified on the command line and prints out all entries in the employees table. Listings 22.9 and 22.10 show the results when connecting to Oracle and Sybase databases, respectively. Listing 22.11 shows a similar class that performs the same database lookup but formats the results in an HTML table. Listing 22.12 shows the raw HTML result.

Listing 22.13 shows the JDBC code used to create the employees table.

Listing 22.8. EmployeeTest.java
 package cwp; import java.sql.*; /** Connect to Oracle or Sybase and print "employees" table. ...

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.