jfreechart displaying chart from access database

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 database
jfreechart 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
line chart from database in jsp
line chart from database in jsp  how can i create line chart from database in jsp code
Displaying file from database
Displaying 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 HTML
ACCESS 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
graph generation using jfreechart and retrieving values from the database
graph generation using jfreechart and retrieving values from the database ... no. of students.The dsn name is chartdsn. I want to retrieve the data from the access... jfreechart API .This whole retrieval and display of chart is to be done in a servlet
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 page
displaying 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
how to show value and percentage in piechart sections from database using jfreechart
how to show value and percentage in piechart sections from database using jfreechart  Hii Sir, I made a pie chart from database using...(query); JFreeChart chart = ChartFactory.createPieChart("Call
image displaying from database with some other information
image displaying from database with some other information  hi, in the following section of code when i am not displaying the image it is working... only a cross mark is shows. same code runs if i am not retriveing any data from
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
jsp programe for displaying data from database
jsp 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 database
jsp 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 database
jsp 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
code for insert the value from jsp to access database
code for insert the value from jsp to access database  code for insert the value from jsp to access database
design chart takes data from database and through jsp page
design chart takes data from database and through jsp page  how can I design chart takes data from database and through in jsp page
sending data to google chart api from mysql database using java
sending data to google chart api from mysql database using java  how to send data from mysql database to google chart api using java
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 problem
Jfreechart 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 database
retreiving 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 Servlet
Extracting 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
How to retrive an inmage from database and displaying it in imgae box - Swing AWT
How to retrive an inmage from database and displaying it in imgae box ...? I want to retrive an image from database and to display it in a small imagebox...(); f.setTitle("Display Image From database"); Image image = f.getToolkit
sending data to google chart api from mysql database using java
sending data to google chart api from mysql database using java  Äîáîâëÿéòåñü â ãðóïïó "ÌÀÉÍÊÐÀÔÒÀ" Áóäüòå ó÷àñòíèêàìè Ãðóïïû Ïîìîãàèòå íàì è ñåáå Íàøà ãðóïïà https://vk.com/club60851464 Åñòü ñâîé ñåðâåð! Õîðîøàÿ àòìîñôåðà
display data from a table in Access Database in a HTML page
display data from a table in Access Database in a HTML page  how to display data from a table in Access Database in a HTML page in a Java Program
displaying List of records from database in a jsp using ajax
displaying List of records from database in a jsp using ajax  Sir, I need to retrieve the records from the database for every 7 seconds and display... data from the database. After getting the response from the servlet am unable
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... from MySQL database and then using the jfree chart library to create chart
to get picture from ms access database by jsp-servlet....
to get picture from ms access database by jsp-servlet....  I have inserted a picture in ms access data base,,,how we can retrieve that picture by using jsp
JFreechart Stacked Bar Chart
JFreechart 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 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..."); dataset.executeQuery(query); JFreeChart chart = ChartFactory.createPieChart("Test
how to fetch data from mysql database table and draw a bar chart on that data using in jsp
how to fetch data from mysql database table and draw a bar chart on that data using in jsp  how to create bar chart fetch data from mysql database using in jsp.please give me a right code. yhanks in advance
retrive the data from access database to drop down list box in jsp
retrive the data from access database to drop down list box in jsp  hai, im new to jsp now im using the jsp along with access database.in table i load all the data's i need to retrive the data from database to dropdown list box
Select Employee and display data from access database in a jtable
Select Employee and display data from access database in a jtable  I... name of the customer is stored in a access database. Below is how it should... a employee's name from a comboBox and the jtable will be filled with all
JFreechart multi line chart help in JSP
JFreechart 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
Add Items in JComboBox from Access Database - Java Beginners
Add Items in JComboBox from Access Database  Heelo Sir I want To add ittem in JComboBox which is stored in Access Database. plz Help Me Sir Database Column name -Course Items -MBA,MCA,MBA IT,MBA FINANCE I want Load Database
How to Open Picture From M.S. Access Database using Java Servlet ?
How to Open Picture From M.S. Access Database using Java Servlet ?  Hi all my Friends I have below code which insert a picture into M.S. Access Database But i m still not able to open this picture through Java using M.S. Access
JFree 3D Bar Chart not displaying in JSP - Java3D
JFree 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
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me   displaying List of records from database in a jsp using ajax, onclick it should display the results
displaying data for a single column from Mysql database in the list box in php form
displaying data for a single column from Mysql database in the list box in php form  I have a form in php.want to display data from a single column...('include/functions.php'); $Select = "SELECT * FROM category_master"; $Q = mysql
how to delete specified coloumn from database(MS Access) by using windows application
how to delete specified coloumn from database(MS Access) by using windows application  how to delete specified coloumn from database(MS Access) by using c# windows application
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
Spring Security Authorized Access with Customized Login from Database
Spring Security Authorized Access with Customized Login from Database In this section, you will learn about authorized access with customized login from database using Spring Security. Sometimes you need to secure your page from
how to show x axis values of timeline chart in jfreechart with particular month.
how to show x axis values of timeline chart in jfreechart with particular month.  my x-axix timeline having day of 1 month and days shows me only differently and 1 month. I want month attached with days
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 format
Displaying 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
How to display Jfreechart from servlet in jsp web page at specified location
How to display Jfreechart from servlet in jsp web page at specified... to display the chart in web page. I generated the chart using Jfreechart in Servlet which is in image format.plz sir give me the code to display this chart
how to retrieve the id value itself from the access database to drop down listbox in jsp
how to retrieve the id value itself from the access database to drop down listbox in jsp  how to retrieves the id which is an int datatype, from access database to drop down list box in jsp...plz send the code for that.....plz
Access 2007 database connectivity
Access 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

Ads