1 Answer(s)      8 years ago
Posted in : JSP-Servlet
View Answers

November 18, 2009 at 3:19 PM

Hi Friend,

Try the following code:

import java.sql.* ;
import* ;
import org.jfree.chart.ChartFactory ;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart ;
import org.jfree.chart.plot.PlotOrientation;
import* ;

public class Chart{
public static void main(String[]args) throws Exception{

String query="SELECT * from chart";
JDBCCategoryDataset dataset=new JDBCCategoryDataset("jdbc:mysql://localhost:3306/test";,

dataset.executeQuery( query);
JFreeChart chart = ChartFactory .createBarChart3D(
PlotOrientation.VERTICAL,true, true, false);
ChartUtilities.saveChartAsJPEG(new File("C:/chart.jpg"), chart, 400, 300);
catch (IOException e)
System.out.println("Problem in creating chart.");



Related Tutorials/Questions & Answers:
Introduction to Graphs and Charts
Introduction to Graphs and Charts       Why Charts and GraphsGraphs... difficult and tedious process. All forms of Graphs and Charts embodies some Visual
Types of Graphs and Charts
Types of Graphs and Charts   ... applications charts and graphs are extensively used for visualizing the data. In Java... the data and call the few methods to generate the charts or graphs of your
graphs/charts - JSP-Servlet
graphs/charts  hi, How to create a graph/chart in java by reading values from my sql database.   Hi Friend, Try the following code: import java.sql.* ; import* ; import org.jfree.chart.ChartFactory
graphs/charts - JSP-Servlet
graphs/charts  hi frens, How to create a bar graph by reading values from mysql database. Please help me out...   Hi Friend, We have used jfreechart library to create a bar graph. And the chart displays
Chart & Graphs Tutorials in Java
;     Best collection of Graphs and Charts Tutorials... to Charts & Graphs Graphs and Charts is the most efficient method...; Types of Charts There are many types of graphs and charts
What is R programming language?
Visualization: It provides various graphs and charts for proper visualization
What is Web Graphics
depiction next to them. It is better to use logos, cartoons, graphs and charts where they make a reasonable sense. Basics Tips