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



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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

 

 

DMCA.com