graph demo

Graph Documentation - Database Access and Data Binding

graph demo[ Home ] [ Products ] [ Downloads ] [ Purchase ]
[ Support ] [ About Us ]

Database Access and Data Binding

Overview
Being able to dynamically generate graphs and charts from data stored in databases in real time makes the graphing functions incredibly powerful.

Security Considerations
In order for an Applet to directly access the data within a database it must be provided with the logon information to that database. If this information is available to an applet then it is also available to anyone else who wishes to obtain it. Hence it is never a good idea to have an applet directly access a database.

To overcome this the Graphing Applets access databases (and other data sources) via Server Side Scripts and Processes. The basic idea is that the graph function will issue a request to such a server side script for the data, this in turn will access the database and return the data back to the graph function. In this way the database logon information is kept securely on the server.

The ./ServerTemplateScripts/ directory of this package contains some example server side scripts which may be adapted for a particular implementation. In addition the Tutorials show these methods in more detail.

Data Interface Scripts can be constructed in any Server Side Scripting Language including, PHP, JSP, ASP, Servlets, Perl etc.

Essential Tutorials and more Database Methods:-

The following describes how to set up the line graph applet to use a Java Servlet to pull the data from a database

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

Table Name : SalesBar
ProductNameText
YearInteger
MonthInteger
ValueDouble
The 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
As you will see from the code (below) the servlet connects to the database via JDBC.

The Data Interface Servlet Code
Custom Solutions
If would like us to perform the set-up process, create custom built data scripts or help with any other part of your web application then we are pleased to offer you the following services:-
Set-Up, Installation and Configuration Service
Web Site Components Development Service
Web Application Development Service
Custom Software Development
JavaScript CSS Image Gallery