O'Reilly logo

Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition by Ivor Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

25.9. Exercises

You can download the source code for the examples in the book and the solutions to the following exercises from http://www.wrox.com.

With some additional features, you'll find the InteractiveSQL utility very useful. Add the following features to InteractiveSQL:

  1. Keep the last ten queries that were executed and allow the user to select from that list of previously run queries.

  2. Provide a menu option that lets the user close the current connection and open a new one. Prompt the user for the URL, driver name, user name, and password.

  3. Modify the program to provide full, detailed information about any SQLException exceptions that are thrown. You may want to use a separate window that provides more space and keeps a running list of exceptions until these are cleared by the user.

There are also lots of potential extensions to the DatabaseBrowse application. Try the following:

  1. It would be more efficient to separate the execution of the SELECT statement from the selection events from the tree. Add a button to execute a SELECT statement with whatever table or columns are selected in the tree.

  2. Extend the application to allow a WHERE condition to be applied. (This is quite hard. You'll need to provide an additional mechanism for specifying the WHERE conditions—which means you'll need to track the columns selected. You could keep a list that you record in the TreeSelectionEvent handler and supply a dialog to allow the condition to be specified.)

  3. Extend the application to allow an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required