Big Data and Hadoop Training @$80 or Rs. 6,000 only - valid till Oct 17th Apply Now!

How to show database values into graph using jsp?

Ads
 

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
Create Line Graph using database values
graph generation using jfreechart and retrieving values from the database
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
how to write the coding for converting the database data for example population into any type of graph using jsp and servlets?//
Draw graph using jsp without database connection
to show graph
JSP1
JSP2
how to show data in database ?
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 show value and percentage in piechart sections from database using jfreechart
How to insert dynamic textbox values into database using Java?
how to display values from database into table using jsp
how to show effect (visual) on jsp page using value from database
how to retrieve image from mysql database using java and show it in HTML img tag ?
How to edit values in textboxes from database using jsp
edit values of database using jsp
edit values of database using jsp
how to retrieve text and images from mysql database and show on html page using jsp servlet
how to store multiple values from drop down in database where i am using java struts 1.3
Navigate database values using up and down key of keyboard
Retrieve values from database using views
How to show data from database in textbox in jsp

Ads