|
Exercises [Short Course| About This Short Course] Exercise Outline
Welcome to the jGuru exercises for the JDBC 2.0 Fundamentals Short Course. These exercises demonstrate selected areas of JDBC, the Java programming language API for accessing tabular and relational data. On completion, you should understand the basic, and some intermediate, steps for creating, accessing, and changing database tables and columns according to the JDBC standard. You will also be aware of and able to use several capabilities that are new with JDBC 2.0. For those new to database engines, be sure that the database you are working with is up and running prior to actually executing any of the exercise programs. The DBMS and the programs work together. All programs have been tested and run properly (with exceptions as noted in the specific exercises) on Cloudscape, UDB2/NT, and DB2/400. The test machine ran NT Server 4.0, SP 6a. For the Cloudscape and UDB2/NT tests, the databases were local to the machine, that is, Cloudscape and DB2 run on the same box as the programs. For AS/400 testing, the application ran on the NT box and DB2/400, of course, being an integrated portion of OS/400, ran on the AS/400. The AS/400 was accessed over a 56Kb Internet connection, using the driver in JTOpen 2.0, which is the open source version of the AS/400 Toolbox for Java. The JDK used was Java 2 Standard Edition 1.3. Following is the DBMS, driver, and version information:
There was a deliberate attempt to provide both more exercises and more "meat" in the exercises than might be expected in a course of this nature. However, this is a short course, targeted at 8 to 12 hours, and you should be aware of several factors that affected the composition of the exercises and regard them accordingly. As in any course, the exercises are aimed at highlighting a specific area under discussion. To the greatest extent possible, the exercises run with little dependence on other programs. As a result, first and foremost, these programs should not be considered production quality. The programs are not optimized as regards the Java programming language, JDBC, or SQL code. For instructional purposes, the programs are monolithic and demonstrate little of the OOPS paradigm. Finally, those exercises that use Swing produce a deprecation warning on compilation, which has to do with using JPasswordField.getText(). This reflects the laziness, and, to a certain extent, the opinion, of the author. About ExercisesA jGuru exercise is a flexible exercise that provides varying levels of help according to the student's needs. Some students may complete the exercise using only the information and the task list in the exercise body; some may want a few hints (Help); while others may want a step-by-step guide to successful completion (Solution). Since complete solutions are provided in addition to help, students can skip an exercise and still complete later exercises that required the skipped one(s). The Anatomy of an ExerciseEach exercise includes a list of any prerequisite exercises, a list of skeleton code to start with, links to necessary API pages, and a text description of the exercise's educational goal. In addition, buttons link you to the following information:
Exercise Design GoalsThere are three fundamental exercise types that you may encounter:
To make learning easier, exercises, where possible, address only the specific technique being taught in that exercise. Irrelevant, unrelated, and overly complex materials are avoided. Where possible, exercises execute on the Web. However, exercises that must access Java features or library elements that could cause security violations are not executed on the web. JDBC 2.0 Fundamentals ExercisesThe fictional scenario for the exercises is the 4J Cafe. Hal Clarke is responsible for information technology for the 4J enterprise. Hal's current contract expires in 2001 and he's determined to have it renewed until at least 2010, when he plans to retire to a small island in the Indian Ocean. To further this end, Hal has engaged the services of Slide and Telly for design, development, and implementation. S&T is owned by Duane Mounds and Chrissie Fore and operates from a home office located in Statesboro, Ohio. Duane and Chrissie support a number of remote clients via email, telephone, internet connections, and the occasional flight. S&T prides itself on professional quality, 24x7 availability, cost benefits produced by leveraging the advantages of their cyberspace workplace and testing, testing, testing. Exercises
This initial example helps you to understand the JDBC code and steps involved in creating and populating a table in a database. Educational goals:
This second example helps you to further understand the JDBC code and steps involved in accessing and retrieving data from a table in a database. Educational goals:
The first course examples hardcoded connection information. This helped to keep things simple at the price of program changes and recompilation for different databases--hardly the Java ideal! This exercise provides a more general method of obtaining the information without user intervention. Educational goal(s):
This exercise reimplements the previous application in a form appropriate for interaction with an end user and includes the ability to dynamically display table data. Educational goal(s):
This exercise demonstrates the flexibility of executeUpdate() and introduces a generalized maintenance application that is enhanced and modified in future exercises. Educational goals:
This exercise focuses on data selection. It introduces the DISTINCT SQL keyword and gives an example of how the data itself can be used to enable dynamic reporting. The exercise works with a third party charting package that you can use in your own applications. Educational goals:
This exercise adds a new column to JJJJData and updates multiple columns with a PreparedStatement to give some ideas as to when prepared statements can be useful. Educational goal(s):
This exercise expands EURun.java, the demonstration program built in Using executeUpdate(), to include complete handling for all SQLExceptions and SQLWarnings. Educational goals:
This exercise retrieves available scalar functions in a DMBS and demonstrates the invocation of selected scalar functions. Educational goals:
This exercise expands EURun2.java, the exercise program built in Handling SQLExceptions and SQLWarnings, to include processing transactions. Educational goals:
This exercise converts the exercise program built in Using Transactions to include batch update functionality and BatchUpdateException handling. Educational goals:
This exercise implements a completely new version of the table viewer in Generalizing Connection Information--Interactive. The application presents data formatted and in a set page size using a scrollable ResultSet. A separate window displays metadata about the table and the ResultSet. Educational goal(s):
This example presents a solution to storing image data in a Blob column, using PreparedStatement's setBinaryStream method. Educational goals:
This exercise demonstrates a method to retrieve and display images stored in a Blob column. Educational goals: Copyright 1996-2000 jGuru.com. All Rights Reserved. | |||||
|
| ||||||||||||