Home Answers Viewqa JSP-Servlet jfreechart displaying chart from access database

 
 


Aarushi Agarwal
jfreechart displaying chart from access database
0 Answer(s)      a year and 6 months ago
Posted in : JSP-Servlet

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 Pages:
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
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
Jfreechart chart display problem
Jfreechart chart display problem  Using JSP and Jfreechart displays the chart fine on an internal browser in eclipse but doesnt display it on Chrome..."); dataset.executeQuery(query); JFreeChart chart = ChartFactory.createLineChart
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...;,"root"); dataset.executeQuery( query); JFreeChart chart
how to generate a bar chart on a JSP PAGE using the arraylist object passed form the servlet.(using jfreechart)
how to generate a bar chart on a JSP PAGE using the arraylist object passed form the servlet.(using jfreechart)  I have created a servlet.In this,i have retrieved a record from MS Access database in an arraylist i.e. my arraylist
create bar chart in jsp using msaccess database
="SELECT * from chart"; JDBCCategoryDataset dataset=new JDBCCategoryDataset("jdbc:odbc...); JFreeChart chart = ChartFactory .createBarChart3D( "Test", "Id", "Score...create bar chart in jsp using msaccess database  thanks for reply
JFreeChart dosn't work
chart from JFreechart, but I just can't get it to work. The graph get its data from at 2-columun database (String, double). (The string is a date, represented... checked that the database contains the data) public class Chart { Connection
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
JFreechart Stacked Bar Chart
JFreechart Stacked Bar Chart JFreechart provides a way to create various... JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new... createChart(final CategoryDataset dataset) { final JFreeChart chart
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
line chart from database in jsp
line chart from database in jsp  how can i create line chart from database in jsp code
JFreeChart - An Introduction
;    JFreeChart is a free open source java chart... JFreeChart library jar files Chart and Dataset In JFreeChart project, you... displays in the chart. JFreeChart have many Dataset objects, that are used to create
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
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...(String[] args) throws Exception { String query = "SELECT * from chart
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
jfreechart
jfreechart  i have added to libraries both of them jcommon-1.0.16.jar and jfreechart-1.0.13 But after adding the code to create bar chart error...... i need to get a bar chart done in my project
Pie chart on jsp
jfreechart which takes values from my databaase??   Here is a jsp code that creates a pie chart using JFreechart api and takes the value from..."); dataset.executeQuery(query); JFreeChart chart = ChartFactory.createPieChart
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
Stacked Bar Chart
Stacked Bar Chart  How to display a stacked bar chart using java from the values stored in the ms access database?Plzz help..its urgent
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
create bar chart in jsp using msaccess database
create bar chart in jsp using msaccess database  type Exception... () that prevented it from fulfilling this request. exception...: JDBCCategoryDataset dataset = new JDBCCategoryDataset("jdbc:odbc:Driver={Microsoft Access
bar chart
bar chart  how to create a bar chart from values of the database and the string value should be the entities of the database??plzz help..needed badly
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
Jfreechart - Java Beginners
how to install and configure JFreechart from the basic with the necessary files...: "Team ", "", data); 24: 25: JFreeChart chart = null...: JFreeChart chart = null; Pls help me to come out frm this issue
displaying data
displaying data   how to display data from database on jsp using struts2
ChartFrame in Jfreechart - JSP-Servlet
am developing line chart in JSP and the code is: My problem is that the chart is created and also saved in the specified location.. But its not displaying on the page i.e chartframe portion
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
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
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
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
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
pie chart
pie chart  hii..how to display data from database and show it in piechart according to different data that is present in database..plzz help
displaying - Ajax
displaying  hi.. im sending request from ajax page to servlet ..as in response i need the get the from database to servlet and from servlet to ajax in column wise.. i have to display the response column wise in the same
how to create bar chart in jsp using msaccess database
how to create bar chart in jsp using msaccess database  type... () that prevented it from fulfilling this request. exception...: JDBCCategoryDataset dataset=new JDBCCategoryDataset("jdbc:odbc:Driver={Microsoft Access Driver
draw chart in web application
draw chart in web application  how to draw bar chat from the record store in database? i.e. draw the bar chart according to selected record
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
How to display jfreechart at specified place in jsp
("Inet", 20); JFreeChart chart = ChartFactory.createPieChart3D...How to display jfreechart at specified place in jsp  I have a jsp page where i need to display the chart at specified position
3d pie chart - Java3D
chart my jsp page is running properly but for 3d i used some code from applet...("Six", new Integer(10)); JFreeChart chart = ChartFactory.createPieChart3D...)); JFreeChart chart = ChartFactory.createPieChart3D ("3D Pie Chart
Displaying images - JDBC
Displaying images  How to display multiple images on a single jsp from MySql database
Displaying images - JDBC
Displaying images  How to display multiple images on a single jsp from MySql database
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
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
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
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
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...(): This method is used to create bar chart for given values. It takes title, dataset
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
JFREE chart - Java Beginners
?the previous one is the one i get every time there is a change in the database..thanks,i want my chart to display dynamically from my database  Hi... database on your chart

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.