How to show database values into graph using jsp?

How to show database values into graph using jsp?

How to show database values into graph using jsp?

View Answers

November 5, 2012 at 11:12 AM

You need to download the jfreechart api and put the jar file inside the lib folder of apache tomcat. Then restart the tomcat server.

<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="org.jfree.chart.ChartFactory" %>
<%@ page import="org.jfree.chart.ChartUtilities" %>
<%@ page import="org.jfree.chart.JFreeChart" %>
<%@ page import="org.jfree.chart.plot.PlotOrientation"%>
<%@ page import="org.jfree.data.*" %>
<%@ page import="org.jfree.data.jdbc.JDBCCategoryDataset"%>
<%@ page import="org.jfree.chart.ChartPanel"%>

<%
String query="SELECT * from chart";
JDBCCategoryDataset dataset=new JDBCCategoryDataset("jdbc:mysql://localhost:3306/chart",
"com.mysql.jdbc.Driver","root","root");

dataset.executeQuery( query);
JFreeChart chart = ChartFactory.createLineChart("Test", "Id", "Score",
                                dataset, PlotOrientation.VERTICAL, true, true, false);
                ChartPanel chartPanel = new ChartPanel(chart);
                chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
                ApplicationFrame f = new ApplicationFrame("Chart");
                f.setContentPane(chartPanel);
                f.pack();
                f.setVisible(true);

try
{
ChartUtilities.saveChartAsJPEG(new File("C:/chart.jpg"), chart, 400, 300);
}
catch (IOException e)
{
System.out.println("Problem in creating chart.");
}
%>









Related Tutorials/Questions & Answers:
How to show database values into graph using jsp?
How to show database values into graph using jsp?
Advertisements
How to show database values in Graph.(Like Cricket score board Graph)
How to show autocomplete textbox values on combo box option selection using database?
How to create bar chart using database values
graph generation using jfreechart and retrieving values from the database
Create Line Graph using database values
show the database values graphical represantation
draw the running or moving graph using database in jsp
draw the running or moving graph using database in jsp
Draw graph using jsp without database connection
JSP2
JSP1
how to read values from excel sheet and compare with database using jsp
How to store values in a database using JSTL? - JSP-Servlet
How to insert dynamic textbox values into database using Java?
how to display values from database into table using jsp
how to show value and percentage in piechart sections from database using jfreechart
to show graph
how to show data in database ?
how to write the coding for converting the database data for example population into any type of graph using jsp and servlets?//
edit values of database using jsp
edit values of database using jsp
how to show effect (visual) on jsp page using value from database
How to edit values in textboxes from database using jsp
how to retrieve image from mysql database using java and show it in HTML img tag ?
Retrieve values from database using views
Navigate database values using up and down key of keyboard
how to store multiple values from drop down in database where i am using java struts 1.3
how to retrieve text and images from mysql database and show on html page using jsp servlet
What is Graph Database
What is Graph Database
How to show data from database in textbox in jsp
ModuleNotFoundError: No module named 'jspp'
ModuleNotFoundError: No module named 'JSPy'
how to show x axis values of timeline chart in jfreechart with particular month.
Line Graph using JFreeChart
how to display the database values in pdf format
how to create own tld and use it in jspx file
how to create own tld and use it in jspx file
How to store extracted values from xml in a database? - XML
How to store extracted values from xml in a database? - XML
Line Graph using JFreeChart
Line Graph using JFreeChart
How to values from xml using java?
how to show image as a link which path coming from database
how to get the values to dropdownlist from oracle database
Create Pie Chart using database values
how can i store text box values as it is in database table
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file

Ads