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.");
}
%>

Ads









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
show the database values graphical represantation
how to read values from excel sheet and compare with database using jsp
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
how to show data in database ?
Draw graph using jsp without database connection
how to show effect (visual) on jsp page using value from 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
JSP2
JSP1
how to retrieve image from mysql database using java and show it in HTML img tag ?
to show graph
how to store multiple values from drop down in database where i am using java struts 1.3
Retrieve values from database using views
how to retrieve text and images from mysql database and show on html page using jsp servlet
How to show data from database in textbox in jsp
how to display the database values in pdf format
how to show x axis values of timeline chart in jfreechart with particular month.
What is Graph Database
What is Graph Database
How to values from xml using java?
how to get the values to dropdownlist from oracle database

Ads