![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]()
(chat, newsreader, calendar)
|
![]() |
|
Course Notes Table of Contents | Exercises JDBC Short Course Index | Online Training Index
|
Help: Selecting |
Working Applet | Help Solution
|
Help is available for each task, or you can go straight to the
source code, which is one particular
solution.
To see if Netcharts installed properly run javap NFBarchartApp to
see if it finds the Bar-Chart class you are going to use.
Use Class.forName to load it, and check for exceptions.
Use the resources read in from the odbc.datasource resource file.
Use Connection.createStatement to do this.
Use Statement.executeQuery to send the SQL SELECT statement. The results will come back as a ResultSet. If you order the results by name,
The ResultSet.findColumn method results in quicker result fetching than using the
column names with the various getString, getInteger, ... methods.
Use ResultSet.next to get each row of the result set.
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.
For instance, the first String should be something like: "John,Mary,Tom".
All the code to generate the chart and put on the screen is included. All you have
to do is setup the variables names and averages.
|
Copyright © 1997 MageLang Institute. All Rights Reserved May-97 Copyright © 1996, 1997 Sun Microsystems Inc. All Rights Reserved |