Technical Support
Discussion Forum
Online Training
Read About Java
Java In-Depth
Product Discounts
Membership Information JDC Resources DukeDollars

Java Cup Logo

JDC Home Page

JDC Applets
(chat, newsreader, calendar)

Log Out

Online Training
shadowSearchFAQFeedback

Course Notes Table of Contents | Exercises
JDBC Short Course Index | Online Training Index

Selecting
Working Applet | Help
Solution

Prerequisites

Skeleton Code

This exercise results in an application that displays a cumulative grade graph for the students at MageLang University. The database contains a single table that contains the names, classes, and grades of all the students. You will need to convert the "A"-"B"-"C" style grades to the numerical equivalence before averaging the grades for the report's graph.

To create the bar chart of the students' average gradess, use the NetCharts package from NetFactory.

NetFactory
www.netcharts.com

After the initial setup, the next several tasks should be familiar. These tasks will not be listed in full later.

Perform the following tasks:

  1. Unzip NetCharts into your current directory.

  2. Copy the odbc.datasource file from the previous exercise.

  3. Import the JDBC package.

  4. Load the sun.jdbc.odbc.JdbcOdbcDriver class.

  5. Create a Connection to the DriverManager.

  6. Create a Statement to perform the query.

  7. Execute a query to select everything from the students table and get the results.

  8. Find out in which columns the name, class, and grade fields are located.

  9. Gather results.

  10. Generate a bar chart from the results. A helper routine, showChartData, is provided, which requires two comma-delimited strings. The first, names, is a list of names, while the other, averages, is a list of their averages. You need to keep each individual's entries at the same position in each list.

    Note: The names and averages variables in the skeleton are StringBuffer variables, not String for performance reasons. StringBuffer.append is much quicker than using the "+" with Strings.

  11. Close the statement.

  12. Close the connection.

The task numbers above are linked to the step-by-step help page. Also available is a complete solution, which meets these requirements, and Expected Behavior.


Copyright © 1997 MageLang Institute. All Rights Reserved
May-97 Copyright © 1996, 1997 Sun Microsystems Inc. All Rights Reserved