Exercises

  1. Run the javadoc tool to create the javadoc files for the packages of the Mckoi database, and browse the API. The database comes with the Java source code that implements it. The file is called src.zip. Unzip it, cd to the src directory that it creates, work out what the package names are (they mirror the directory names), and run javadoc on them. Look at some of the source code with an editor, and browse the javadoc-generated API documentation for the same files. How useful is javadoc to you? Why? How far does the code follow the Sun recommended code conventions at java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html ?

  2. Write a JDBC program to display the name and age of everyone in the Person table who is older than 39. This question builds on a similar one in Chapter 23 that asked you to write the SQL statement. Now the exercise asks that you put it into a JDBC program and actually run it.

  3. Write a JDBC program to display the name of everyone in the Person table who lives in a NATO country and doesn't listen to the Beatles. You can google to find out which nations belong to NATO. Be careful to exclude people who listen to other bands as well as the Beatles. You will need a subquery for this.This question builds on a similar one in the previous chapter that asked you to write the SQL statement. Now the exercise asks that you put it into a JDBC program and actually run it.

  4. Modify your program from the previous question to submit an invalid SQL query. How do the database and your program respond?

  5. Write the JDBC code to create and populate a table for the CD inventory of an online store. Each CD is either domestic or imported. These details are stored for all CDs: artist, title, price, and quantity in stock. Imported CDs also have these fields: country of origin, genre, non-discount status, language, and lead time for reorder. Write some instance data describing your five favorite CDs (include a couple of imported CDs, too), and populate your database.

  6. Update your code from the previous exercise question to allow it to work interactively with the user. The user should be able to type in the title of a CD, and the database should return all the data it holds on that CD.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.151.32