graph chart

2D/ 3D Stacked Horizontal Bar Graph Examples

[ Bar Graph Home ] [ Tutorials ] [ Documentation ] [ Getting Started ] [ Solutions ]

Applet Example 6 - Data from a Database

if you do not see the graph below then click here

This example demonstrates how to implement the applet so that the graph data is acquired from a database. Here we set up the applet to acquire the configuration data from a text file and the graph data from a server side process which in turn acquires the data from a database.

The Graphing Software provides several methods by which data can be acquired from databases. For a full discussion on the various methods and Template Scripts please see the
Tutorial Section.

The configuration data is acquired from the text file barprops.txt (click here to view)

The DatabaseServletSHbar is designed to retrieve product sales data from a MySQL database, from a table with the following structure,

Table Name : SalesBar
ProductName Character
Year Integer
Month Integer
Value double

 

Our servlet will pick out the sales figures for three products ( ProductX, ProductY and ProductZ) and return the data in the correct format for the graph.

The method is as follows,

  • Set the output characteristics for the return data
  • Establish the database connection
  • Build the query statement and retrieve the database records
  • Process the database records and return the Data
  • All finished so close the database connection

The full servlet code is contained in the DatabaseServletSHbar file.
(Click here to view the code).

As you will see from the code the servlet connects to the database via JDBC and as such it is essential to have the correct JDBC drivers for your database. ( For further information on JDBC drivers please see http://industry.java.sun.com/products/JDBC/drivers )

 

For a full explanation of and range of values for the above parameters please see the Documentation - Configuration Options».

« back to Examples Index

« back to Getting Started

[ Bar Graph Home ] [ Tutorials ] [ Documentation ] [ Getting Started ] [ Solutions ]

 

Getting Started

Documentation

Examples

Tutorials

Common Problems
This section describes and provides solutions to common problems.