jfreechart displaying chart from access database
I have these 2 codes.
array.java----in which i retrieve the values from the database .
import java.util.ArrayList;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author AARUSHI
*/
class database
{
int roll;
String name;
int marks1;
int marks2;
int marks3;
int marks4;
public database(int r,String nm,int m1,int m2,int m3,int m4)
{
roll=r;
name=nm;
marks1=m1;
marks2=m2;
marks3=m3;
marks4=m4;
}
@Override
public String toString()
{
return roll + ":" + name + ":" + marks1 + ":" + marks2 + ":" + marks3 + ":" + marks4;
}
}
public class arraylist extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
ArrayList<database> v = new ArrayList<database>();
database db;
try {
int rollno=Integer.parseInt(request.getParameter("txtroll"));
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:cdotdsn");
PreparedStatement ps=con.prepareStatement("select * from cdottable where rollno=?");
ps.setString(1,""+rollno);
ResultSet rs=ps.executeQuery();
out.println("hello1");
while(rs.next())
{
// out.println("1st "+rs.getString(1));
// out.println("2nd "+rs.getString(2));
//out.println("3rd "+rs.getString(3));
//out.println("4th "+rs.getString(4));
// out.println("5th "+rs.getString(5));
// out.println("6th "+rs.getString(6));
int r=Integer.parseInt(rs.getString(1));
String nm=rs.getString(2);
int m1=Integer.parseInt(rs.getString(3));
int m2=Integer.parseInt(rs.getString(4));
int m3=Integer.parseInt(rs.getString(5));
int m4=Integer.parseInt(rs.getString(6));
out.println(r+ nm + m1 + m2 + m3 + m4);
out.println("abc");
db=new database(r,nm,m1,m2,m3,m4);
v.add(db);
int m=v.size();
out.println(m);
out.println( v );
}
con.close();
}
catch(Exception e)
{
out.println(e);
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
and a jfreechart file to display the chart.this is a separate java file.
graph.java
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
public class barchart {
public static void main(String[] args) {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(6, "Marks", "sem1");
dataset.setValue(7, "Marks", "sem2");
dataset.setValue(8, "Marks", "sem3");
dataset.setValue(5, "Marks", "sem4");
dataset.setValue(12, "Marks", "sem5");
JFreeChart chart = ChartFactory.createBarChart("MARKS INFORMATION OF THE ENTERED STUDENT",
"SEMESTER", "MARKS", dataset, PlotOrientation.VERTICAL,
false, true,false);
ChartFrame frame=new ChartFrame("student graph",chart);
frame.pack();
frame.setVisible(true);
}
}
NOW i want that these both things should be done in a single servlet and then the chart should be displayed on a jsp..how can i do it..pls reply..its urgent.
View Answers
Related Tutorials/Questions & Answers:
jfreechart displaying chart from access databasejfreechart displaying chart from access database I have these 2 codes.
array.java----in which i retrieve the values
from the
database .
import...");
JFreeChart chart = ChartFactory.createBarChart("MARKS INFORMATION
jfreechart display from access database data.jfreechart display
from access database data. I have made a
database... 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 Advertisements
Displaying file from databaseDisplaying file
from database I have list of files in my
database. I... that corresponding file
from database. I have list of file id related to search. I want... *
from file";
ResultSet rs = stmt.executeQuery(strQuery);
while(rs.next
ACCESS DATABASE FROM HTMLACCESS DATABASE FROM HTML I want to
access sql 2008
database in html page without help of ADODB connection.. because if
access through ADODB means there is a security problem. so,
Access database in html page(client side
How to access the database from JSP?How to
access the
database from JSP? Hi,
What is the process of accessing the
database from JSP page?
Thanks
Hi,
In the JSP program...
database from JSP which explains you how to
access the
database by embedding
displaying data retrieved from a database in a jsp pagedisplaying data retrieved
from a
database in a jsp page the page should display username, emailid, telephone in addition to tthe tagline however... sql = "select billid, customerid, billdate, status
from customerbills where
make chart or graph from database - Java Beginnersmake
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
jsp programe for displaying data from databasejsp programe for
displaying data
from database i am using JSP.i want to insert data into
database and also want to display the things i have entered..."')");
ResultSet rs = stmt.executeQuery( "SELECT *
FROM data");
String id
jsp programe for displaying data from databasejsp programe for
displaying data
from database i am using JSP.i want to insert data into
database and also want to display the things i have entered..."')");
ResultSet rs = stmt.executeQuery( "SELECT *
FROM data");
String id
jsp programe for displaying data from databasejsp programe for
displaying data
from database i am using JSP.i want to insert data into
database and also want to display the things i have entered..."')");
ResultSet rs = stmt.executeQuery( "SELECT *
FROM data");
String id
How to access (MySQL)database from J2ME?How to
access (MySQL)
database from J2ME? I am new to J2ME. I am using NetBeans.
Can anyone help me?
How to
access (MySQL)
database from J2ME?
( I search a lot I found that there is need to
access database through servlet
Jfreechart chart display problemJfreechart chart display problem Using JSP and
Jfreechart displays...(request.getParameter("
q"));
String query="select dateof,dayinprice,company
from stockprice...");
dataset.executeQuery(query);
JFreeChart chart = ChartFactory.createLineChart
retreiving data from microsoft access databaseretreiving data
from microsoft
access database How can i retrieve data
from microsoft
access when i have select the vaules in combo box and text box. When i select these values... i want to retrieve the corresponding columns
Extracting table from Access Database to ServletExtracting table
from Access Database to Servlet Sir,
I have... show 900.
I have written the query as : Select sum(h1)
from expend where head_id...();
ResultSet res=stat.executeQuery("select SUM(ne)
from expenditure1 where headid=H1
Create Bar Chart with database valuesCreate 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...
from MySQL
database and then using
the jfree
chart library to create
chart JFreechart Stacked Bar ChartJFreechart Stacked Bar
Chart
JFreechart provides a way to create various... = createDataset();
final
JFreeChart chart = createChart(dataset);
final ChartPanel...
JFreeChart createChart(final CategoryDataset dataset) {
final
JFreeChart chart Create Pie Chart using database valuesCreate Pie
Chart using
database values
Java provides
JFreeChart library which... a pie
chart by retrieving the values
from the
database.
Here is the code...");
dataset.executeQuery(query);
JFreeChart chart = ChartFactory.createPieChart("Test
JFreechart multi line chart help in JSPJFreechart multi line
chart help in JSP Hi,
I am am looking for and help in getting multi line
chart with Jfree
chart, i had manage to write...");
dataset.executeQuery(query);
//(final XYDataset dataset){
final
JFreeChart chart JFree 3D Bar Chart not displaying in JSP - Java3DJFree 3D Bar
Chart not
displaying in JSP Hi
I am trying to run JFree 3D bar
chart written in your site under link:
http://www.roseindia.net/chartgraphs/3Dbarchart-in-jsppage.shtml
This is not working. PNG file
Create a polar chart using JFreeChart Create a polar
chart using
JFreeChart
... a polar
chart using
JFreeChart. Code given below creates a simple
polar
chart....
createPolarChart(): This method is used to create bar
chart for given values. It
takes
Stacked Bar Chart using JFreeChart Stacked Bar
Chart using
JFreeChart
... bar
chart using
JFreeChart.
In the code given below we have extended class....
createStackedBarChart(): This method is used to create stacked bar
chart for given values
Draw Statistical chart in jsp chart in jsp by
getting values
from database..
To draw a bar
chart, we have used
JFreeChart Library.
JFreeChart is a
chart library used to generate different...;%
String query="SELECT *
from chart";
JDBCCategoryDataset dataset=new
Stacked Bar Chart Example using JFreeChart Stacked Bar
Chart Example using
JFreeChart... a Stacked bar
chart using
JFreeChart. Bar
chart will represent scores
of two team... to create stacked bar
chart for given values.
It
takes title, domain axis
Displaying database values in pdf formatDisplaying database values in pdf format Hi All,
I am... the form the values are stored in
database,the
database name is registration...
database values should be shown as pdf or excel format.
Thanks in advance
JFreeChart - An Introduction;
JFreeChart is a free open source java
chart... with required
JFreeChart library jar filesADS_TO_REPLACE_2
Chart and Dataset
In
JFreeChart project, you have to create a
Dataset for creating a
chart Access 2007 database connectivityAccess 2007
database connectivity i design an application form... and Exit. when i click at SAVE Button than it doesn't save the selected item
from source and destination. pls tell me the code of connectivity with
access 2007