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
edit values of database using jsp
edit values of database using jsp
how to write the coding for converting the database data for example population into any type of graph using jsp and servlets?//
how to retrieve image from mysql database using java and show it in HTML img tag ?
JSP1
JSP2
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.
How to values from xml using java?
What is Graph Database
What is Graph Database
how to get the values to dropdownlist from oracle database
how to show image as a link which path coming from database
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
Line Graph using JFreeChart
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..
how to show set of images continously using JScrollpane in java
how to show set of images continously using JScrollpane in java
How to update,Delete database values from jtable cells ..
How to save database data into excelsheet using hibernate
how to connect to database in php using mysql
how to create own tld and use it in jspx file
how to create own tld and use it in jspx file
How to extract values from SOAP Response message and insert in database
How to fetch entries/values from database to a jsp page one by one?
how to set values in object using java and what are the ways?
How to delete the row from the Database by using servlet
Line Graph using JFreeChart
Line Graph using JFreeChart

Ads