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



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

Have Programming Question? Ask it here!
 
 
 


Aarushi Agarwal
jfreechart displaying chart from access database
0 Answer(s)      2 years and 9 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.


Advertisement
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
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...(request.getParameter("q")); String query="select dateof,dayinprice,company from stockprice..."); dataset.executeQuery(query); JFreeChart chart = ChartFactory.createLineChart
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
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
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 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
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
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
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
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
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
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
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
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 Есть свой сервер! Хорошая атмосфера
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
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
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
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 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
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
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
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
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
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
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
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
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
Category Step Chart Example using JFreeChart
Category Step Chart Example using JFreeChart... a category step chart using JFreeChart. Code of the chart shows you run rate... for create data set according to the category. JFreeChart: JFreeChart class
Stacked 3d Bar Chart Example using JFreeChart
Stacked 3d Bar Chart Example using JFreeChart... a Stacked 3d bar chart using JFreeChart. Bar chart will represent the score... is used to create stacked bar chart for given values. It takes title, domain
Box And Whisker Chart Example using JFreeChart
Box And Whisker Chart Example using JFreeChart... to create a box and whisker chart using JFreeChart. Code of the chart given below...(): This method is used to create box and whisker chart for given values. It takes title
Create a pie chart in jsp page using JFreeChart
Create a pie chart in jsp page using JFreeChart... to create a pie chart in jsp page using JFreeChart. Code given below creates a simple pie chart for given values. In the code given below we have extended class
Candle Stick Chart Example using JFreeChart
Candle Stick Chart Example using JFreeChart... a candle stick chart using JFreeChart. Code of the chart given below shows... createBoxAndWhiskerChart(): This method is used to create box and whisker 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
Create a dual axis chart using JFreeChart
Create a dual axis chart using JFreeChart  ... a dual axis chart using JFreeChart. Code given below creates a simple dual axis chart for a match. In the code given below we have extended class
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
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
Horizontal Bar Chart Example using JFreeChart
Horizontal Bar Chart Example using JFreeChart... a Horizontal bar chart using JFreeChart. This example showing you match.... createBarChart():  This method is used to create bar chart for given values
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
Create a bar chart in JSP page using JFreeChart
Create a bar chart in JSP page using JFreeChart... to create a bar chart in JSP page using JFreeChart. Code given below creates a bar chart...(): This method is used to save chart in to png format. jspbarchart.jsp
Create area chart in JSP page using JFreeChart
Create area chart in JSP page using JFreeChart... to create a area chart in JSP page using JFreeChart. Code given below creates a area chart of runs of two teams in different matches. In the code given below we
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
Advertisements
 

 

 

DMCA.com