Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet graph generation using jfreechart and retrieving values from the database

Have Programming Question? Ask it here!
 
 
 


Aarushi Agarwal
graph generation using jfreechart and retrieving values from the database
1 Answer(s)      2 years and 10 months ago
Posted in : JSP-Servlet


I have made a database containing 4 subject marks and name and roll no. of students.The dsn name is chartdsn. I want to retrieve the data from the access database using prepared statement and then display the bar graph using jfreechart API .This whole retrieval and display of chart is to be done in a servlet..

Note that it is a access made database.

How can I proceed ..Pls answer.Its very urgent.

I got this answer but i need to know the meaning of this line JDBCCategoryDataset dataset=new JDBCCategoryDataset("jdbc:odbc:student", "sun.jdbc.odbc.JdbcOdbcDriver","root","root");

what is student here and how the data is being retrieved. The answer given is below.. Answer:

Follow these steps:

1)Go to the start->Control Panel->Administrative Tools-> data sources.

2)Click Add button and select the driver Microsoft Access Driver(*.mdb).

3)After selecting the driver, click finish button.

4)Then give Data Source Name and click ok button. er 5)Your DSN will get created.

6) Restart your tomcat server and run your jsp code.

<%@ 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"%>

<%
String query="SELECT * from chart";
JDBCCategoryDataset dataset=new JDBCCategoryDataset("jdbc:odbc:student",
"sun.jdbc.odbc.JdbcOdbcDriver","root","root");

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

please reply its very urgent..how to do it.


Advertisement
View Answers

November 9, 2011 at 11:40 AM


student is our dsn name and as far as JDBCCategoryDataset is being concern, it is a class provided by JFreechart. This class provides the implementation over a database JDBC result set. Its constructor consists of url, driver, user, pass to connect to the database. The dataset is populated via a call to executeQuery(String) with the string SQL query.



Related Tutorials/Questions & Answers:
Create Line Graph using database values
Create Line Graph using database values JFreeChart library has made... retrieved from the database. In this section, you will learn how to create a x-y line graph by retrieving the values from the database. Here is the code: import
Create Pie Chart using database values
Create Pie Chart using database values Java provides JFreeChart library which... a pie chart by retrieving the values from the database. Here is the code... void main(String[] args) throws Exception { String query = "SELECT * from
Advertisements
make chart or graph from database - Java Beginners
make chart or graph from database  d, I want to ask about how to make a chart or graph. First i have Table name= "customer" and field =(cust_id... customer come to me. in this chart have two values nm_id and date. Please give
Create Bar Chart with database values
Create Bar Chart with database values In this section, you will learn how to create a bar chart by retrieving the values from the database. For this purpose, we have used JFreechart api. The class JDBCCategoryDataset of this api provides
getting values from database - JSP-Servlet
getting values from database  I tried the following code abc.html aaa.jsp I am not getting exceptions now... JSP code separately.If it will not display database values then try your code
how to insert list box in java script dynamically and elements retrieving from database like oracle
how to insert list box in java script dynamically and elements retrieving from database like oracle  hi all, how can i insert elements into java script list box retrieving from Database. whenever I insert any element in the Db
how to insert list box in java script dynamically and elements retrieving from database like oracle
how to insert list box in java script dynamically and elements retrieving from database like oracle  Hi, how to dynamically increase size of list box in javascript when elements retrieving from database.. That is whenever I
database retrieving - JDBC
database retrieving  how to retrieve resultset from table which we have created in 'SQL SERVER MANAGEMENT STUDIO' using java program
Navigate database values using up and down key of keyboard
Navigate database values using up and down key of keyboard In this section, you will learn how to navigate database values using up and down keys... the database values. On pressing the up key, the following code will fetch one by one
Retrieving attribute value from XML
Retrieving attribute value from XML  I have an XML as below to parse: <LoadTicketRequest> <LoadTicket LoadTicketID="S-123345">...-values-from-a-nodel.shtml http://www.roseindia.net/xml/dom/GetData.shtml Thanks
jfreechart
jfreechart  hi how install jfreechart? and how free download jcommon? plz insert link for this? thanks   Hi Friend, Please visit the following link: Download JFreechart Download jfreechart-1.0.13.zip from the given
Connecting to MySQL database and retrieving and displaying data in JSP page
Connecting to MySQL database and retrieving and displaying data in JSP page... from the database. In this example we will use tomcat version 4.0.3 to run our web application. Creating Table in the database. Using a JDBC driver
Database values in JComboBox
Database values in JComboBox In this section, you will learn how to display values in JComboBox from database. For this, we have allowed the user to enter any character as a key in the textbox .Based on this key value, the results from
Create Histogram using Jfreechart
Create Histogram using Jfreechart In this section, you will learn how to create histogram using jfreechart. To create a Histogram, we have used... of ten randomly generated numbers to the dataset, using the specified number
retrieving of value from excel file - JSP-Servlet
retrieving of value from excel file  Dear sir, Thanks for sending... that excel sheet i.e this matter will take a para meter values from the excel... now i want a single content that should take the parameter values from the excel
retrieving of value from excel file - JSP-Servlet
retrieving of value from excel file  Dear sir, Thanks for sending... that excel sheet i.e this matter will take a para meter values from the excel... now i want a single content that should take the parameter values from the excel
retrieving of value from excel file - JSP-Servlet
retrieving of value from excel file  Dear sir, Thanks... for snding a massmails,now i have to get a particular column values i.e Name(A),EL(B... onl single column value i.e EmailId values to send for a different employees
Acees data from database using combo box - JSP-Servlet
Acees data from database using combo box  please let me how i access the data from database when i select combo box combo2 having values Arts...("show.jsp?class_name="+cla+"&&from_year="+y1+"&&to_year="+y2+"&&school="+sch
JFreechart Stacked Bar Chart
JFreechart Stacked Bar Chart JFreechart provides a way to create various charts by just using the methods of different classes. You are well aware of bar... on top of one another which is an effective way to communicate the absolute values
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
dynamic generation of html:select tag from textbox value
dynamic generation of html:select tag from textbox value  Hi, I am a newbie to java and struts. In my application, I have a requirement like when i... action class? And i have no idea how to implement this. I am using jsp. Any help
retrieving image files - JSP-Servlet
retrieving image files  How to retrieve multiple images at a time from mysql database using JSP
connect to the database from JSP
connect to the database from JSP  How do you connect to the database from JSP?   A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets
how i conditional access the data from database using combo box. - JSP-Servlet
how i conditional access the data from database using combo box.   i... appears named Subject values Arts, Commerce, Science. how i conditional access the data from database when i select class 11 0r 12. Here is JSP file
How retreive data from database without using post method in jsp - JSP-Servlet
How retreive data from database without using post method in jsp  Tell me how?  Hi Friend, If you don't want to use post method then use... the selected value from the combo box and get textbox value from another page
selecting data from database
selecting data from database  how to select data from database using Dao in struts   Hi, You have to load the data from database using hibernate and send the data in a Java file object to jsp page. Please read at http
Jfreechart setting Legends - Java Beginners
Jfreechart setting Legends  Hi... i am using JfreeChart in my web app. for creating charts.I am trying to make the legends as vertical in Stacked bar chart. Does anybody know How to set the legends in any graph as vertical
How to export data from database to excel sheet by using java swing in standalone project - Java Beginners
How to export data from database to excel sheet by using java swing... database to excel sheet by using java swing in standalone project.I get solution from..., that will take the database vales from JTable to Excel sheet. import
How to retrieve data from database by using combo box value in jsp? - JSP-Servlet
How to retrieve data from database by using combo box value in jsp?  Hello friend i want use only one jsp page.. but u give 2 pages... I want to work in one page... Pl response.. I do not need getParameter... Pl respose me
Representing Graph using adjacency list & perform DFS & BFS
Description: This tutorial demonstrate how to create a graph using adjacency list and perform DFS and BFS. Different kind of graph are listed below... if from any node you can reach any other node. Disconnected: A graph is said
avoid duplicate values using struts - Struts
avoid duplicate values using struts  How to avoid the duplicate values in Struts?  IN action class you check before storeing itSee howFirst your storing data and database data both you check using any method and help
how to get a values from processRecord - JSP-Servlet
how to get a values from processRecord  dear sir, i have a problem in getting a values from java to jsp.Here jsp is used to read a excel sheet that intern call a java program so i want a column values i.e a column contains
PHP Returning Values from Function
Returnig Values from function: From a function we can return values using optional return statement, in PHP we can return arrays, objects. With the help of the return statement the control moves back to the calling portion
Jfreechart zoomin and zoomout - Framework
Jfreechart zoomin and zoomout  how to zoomin and zoom out chart using button plus and minus or slide bar in jFree chart
To retrieve image from SQL Server Database - Java Server Faces Questions
To retrieve image from SQL Server Database  Sir/Madam, I am trying to retrieve image from SQL Server 2000 database in Visual Web JSF Page using... or in Image Component. please help me in retrieving and displaying image from SQL Server
delete data from database - SQL
delete data from database  HOw to delete specific data from table> I want to delete one record from database. Thnx  Hi friend, -------------------------------------------- Visit for more information
Retrieving cells in MySQL - JDBC
Retrieving cells in MySQL  Hi, Am creating an online exam application using JSP & MySql.The exam is of objective nature with four choices each... of the database and evaluate the answers for a score. Regards, Prem
Accessing Database from servlets through JDBC!
Accessing Access Database From Servlet    This article shows you how to access database from servlets...;emaildb.mdb" database from unzipped folder. Compile you
store and retrive image from database - JDBC
an image in database using java?  Hi friend, Code for store image in database using Java. import java.sql.*; import java.io.*; public class...()); } } } For retrieve image from database visit to : http
Displaying Constant values from Interface in JSP - JSP-Servlet
Displaying Constant values from Interface in JSP  Hi, ******Sorry... I am directly using the values instead of the constant variables for displaying... for using those constants instead of values::::"PROJ100"; Thank's
retriving image from database - JSP-Servlet
retriving image from database  how to retrive image from mysql database by using servlet programming  Hi Friend, Please visit the following link: http://www.roseindia.net/servlets/retreiveimage.shtml Thanks
Connecting to Database from a hyperlink in JSP - JSP-Servlet
Connecting to Database from a hyperlink in JSP  How can I connect to database by clicking on a hyperlink in a JSP Page.Can you please give me sample... which is connect to database using jdbc database
JFreeChart- Display coordinate value .
JFreeChart- Display coordinate value .  How to Mark Coordinte value on top of the bar
how to get a values from a multipart/form-data - JSP-Servlet
how to get a values from a multipart/form-data  Dear sir , I used your code for getting a values,i used the fllowing function... ,matter,file field values but not status and from field i am getting null
Table generation error - EJB
Table generation error  Hi friends I am using EJB3.0 with sun java system application server 9.1 with postgresql database. Actually when i make... into the database. [#|2008-09-08T11:35:59.453+0200|WARNING|sun-appserver9.1
How to return multiple values from a method - Java Beginners
How to return multiple values from a method  I came the following method "How do I return multiple values from a method?" posted elsewhere..."; /** * This is returning a single Object, which contains * multiple values
How to return multiple values from a method - Java Beginners
How to return multiple values from a method  I came the following method "How do I return multiple values from a method?" posted elsewhere..."; /** * This is returning a single Object, which contains * multiple values
not able to get values from jsp file - JSP-Servlet
not able to get values from jsp file  hi thanks for u feedback... the value by using method request.getParameter(). it shows null value,but if i remove encrtype from form tag its work fine please go through the file
radar graph in java
radar graph in java  Hi All I am developing a java application...(new StandardCategoryToolTipGenerator()); JFreeChart chart = new JFreeChart... jfreechart api. Thanks
 

 

 

DMCA.com