JSP Page show report on specific time interval

Ads
 

JSP Page show report on specific time interval

I want to display the report at the specific time from the data base in my JSP page

View Answers

November 16, 2011 at 12:36 PM

Here is the program and you need a xml file where your sql qurys would be there.

catgory.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" 
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="PDFReport" pageWidth="975">
<reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="15" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="15" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="12" isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<parameter name="id" class="java.lang.Integer"/>
<parameter name="ReportTitle" class="java.lang.String"/>

<queryString><![CDATA[SELECT Stu_Id, Stu_Name, Stu_Class FROM stu_table_backup WHERE Stu_Id=$P{id}]]></queryString>
<field name="Stu_Id" class="java.lang.Integer"/>
<field name="Stu_Name" class="java.lang.String"/>
<field name="Stu_Class" class="java.lang.String"/>
<title>
    <band height="50">
      <textField>
        <reportElement x="350" y="0" width="200" height="50" />       
        <textFieldExpression class="java.lang.String">$P{ReportTitle}</textFieldExpression>
      </textField>
    </band>
</title>
 <pageHeader>
    <band>
    </band>
  </pageHeader>
 <columnHeader>
    <band height="20">
      <staticText>
        <reportElement x="0" y="0" width="100" height="20"/>
        <textElement>
          <font isUnderline="false" reportFont="Arial_Bold"/>
        </textElement>
        <text><![CDATA[Stu_Id]]></text>
      </staticText>
     <staticText>
        <reportElement x="125" y="0" width="100" height="20"/>
        <textElement>
          <font isUnderline="false" reportFont="Arial_Bold"/>
        </textElement>
        <text><![CDATA[Stu_Name]]></text>
      </staticText>
      <staticText>
        <reportElement x="250" y="0" width="150" height="20"/>
        <textElement>
          <font isUnderline="false" reportFont="Arial_Bold"/>
        </textElement>
        <text><![CDATA[Stu_Class]]></text>
      </staticText>



    </band>
  </columnHeader>
<detail>
    <band height="20">
      <textField>
        <reportElement x="0" y="0" width="100" height="20"/>


        <textFieldExpression class="java.lang.Integer"><![CDATA[$F{Stu_Id}]]></textFieldExpression>
      </textField>
      <textField pattern="0.00">
        <reportElement x="125" y="0" width="100" height="20"/>
        <textFieldExpression class="java.lang.String"><![CDATA[$F{Stu_Name}]]></textFieldExpression>
      </textField>

      <textField pattern="0.00">
        <reportElement x="250" y="0" width="150" height="20"/>
        <textFieldExpression class="java.lang.String"><![CDATA[$F{Stu_Class}]]></textFieldExpression>
      </textField>



    </band>
  </detail>
<columnFooter>
    <band>
    </band>
  </columnFooter>
<pageFooter>
    <band height="15">
      <staticText>
        <reportElement x="0" y="0" width="40" height="15"/>
         <textElement>
          <font isUnderline="false" reportFont="Arial_Italic"/>
        </textElement>
        <text><![CDATA[Page #]]></text>
      </staticText>
      <textField>
        <reportElement x="40" y="0" width="100" height="15"/>
        <textElement>
          <font isUnderline="false" reportFont="Arial_Italic"/>
        </textElement>
        <textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
      </textField>
    </band>
  </pageFooter>
<summary>
    <band>
    </band>
  </summary>
</jasperReport>

java program

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author chandan
 */
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.*;

import java.util.HashMap;

import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperPrintManager;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.export.JRXlsExporter;

public class Report {

    public static void main(String args[]) {
        JasperReport jasperReport;
        JasperPrint jasperPrint;
        Connection con = null;
        Statement smt = null;

        try {
            HashMap jasperParameter = new HashMap();

            Class.forName("com.mysql.jdbc.Driver");
            String URL = "jdbc:mysql://localhost:3306/test";
            con = DriverManager.getConnection(URL, "root", "root");
            jasperParameter.put("id", new Integer(4));
            jasperReport = JasperCompileManager.compileReport("C:/catalog.xml");
            jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, con);
            JasperPrintManager.printPage(jasperPrint, 0, true);

           // JRXlsExporter exporter = new JRXlsExporter();
       // exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
      //  exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "E:/simple_report.xls");
      //  exporter.exportReport();

        } catch (Exception e) {
            e.printStackTrace();
        }




    }
}

Just try it.it will work

Ads









Related Tutorials/Questions & Answers:
MySql Time Interval
MySql Time Interval This example illustrates how to get date and time between specific time interval. In this example we create a query "select...; to find the data between specified interval. The BETWEEN and AND keyword are used
how to set time in jsp page
how to set time in jsp page   I need code for set the time in jsp code .iam using struts frame work back end oracle 10g ide is eclipse 6.0
Advertisements
ModuleNotFoundError: No module named 'report-on-interval'
ModuleNotFoundError: No module named 'report-on-interval'  Hi, My... named 'report-on-interval' How to remove the ModuleNotFoundError: No module named 'report-on-interval' error? Thanks   Hi, In your
uitableviewcell loading time interval
uitableviewcell loading time interval  How can i check the time interval between loading the two cells in UITableViewCell? Please suggest. Thanks... time intervals between two cells in XCode. Just see the given lines of code
Show image and text on same jsp page
Show image and text on same jsp page  Hi all, I have to display image and text on the same jsp page. The text and image are both retrived from mysql database. The image is shown correctly on seperate jsp page but when shown
how to show effect (visual) on jsp page using value from database
how to show effect (visual) on jsp page using value from database  I am making a ticket booking system. I have a databse with a clumn "booking status" I am thinking to use a map of seats ( with pictures controllers as seats) What
HOW TO SHOW TIME SERIES
HOW TO SHOW TIME SERIES  hi................ i require a small code in java swings to display the output as time series. Can u plz help???????? Reply....... thanks in advance
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... increasin 1 in the previously stored tsk id) on JSP page when I click... tasks id as primay key, I am using JSP and struts for database connectivity,Now I
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... increasin 1 in the previously stored tsk id) on JSP page when I click... tasks id as primay key, I am using JSP and struts for database connectivity,Now I
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I can update my database but i want to autogenerate tasks id in numbers on JSP
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... increasin 1 in the previously stored tsk id) on JSP page when I click... tasks id as primay key, I am using JSP and struts for database connectivity,Now I
ModuleNotFoundError: No module named 'show-time'
ModuleNotFoundError: No module named 'show-time'  Hi, My Python... 'show-time' How to remove the ModuleNotFoundError: No module named 'show... have to install padas library. You can install show-time python with following
Adding image to database through jsp or HTML page ,while adding only image should show.
Adding image to database through jsp or HTML page ,while adding only image should show.   Adding image to database through jsp or HTML page... different jsp or HTML page. please help me. Thanks in Advance
JSp session time out
JSp session time out  Consider a case where we are working on a java... the maximum time in seconds before a session becomes invalid. Its syntax is: session.setMaxInactiveInterval(int interval); And if you want to specify
how to retrieve text and images from mysql database and show on html page using jsp servlet
how to retrieve text and images from mysql database and show on html page using jsp servlet  <%@ page language="java" contentType="text/html... {color:blue} <%@ page import="java.sql.*" %> <%@ page import
hide and show result in jsp
="sql" uri="http://java.sun.com/jsp/jstl/sql"%> <%@ page language ="java...="http://java.sun.com/jsp/jstl/sql"%> <%@page import="java.sql.*"%>...hide and show result in jsp  what codes do i have to change to make
ModuleNotFoundError: No module named 'show-current-time'
ModuleNotFoundError: No module named 'show-current-time'  Hi, My... named 'show-current-time' How to remove the ModuleNotFoundError: No module named 'show-current-time' error? Thanks   Hi, In your
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
JSP handle run-time exceptions
JSP handle run-time exceptions  How does JSP handle run-time exceptions?   You can use the errorPage attribute of the page directive... the browser to the JSP page error.jsp if an uncaught exception is encountered during
Show pdf's in web browser by using jsp?
Show pdf's in web browser by using jsp?  Hi, I want to display pdf file in browser by clicking the link, available in JSP page. When am trying... status - 404. How can i resolve it in JSP
Nb hours between 2 time stamps meets specific criteria
Nb hours between 2 time stamps meets specific criteria  sql - I have 2 columns with time stamps and 2 empty columns, named DAYHOURS AND NIGHTHOURS. I want to update DAYHOURS and NIGHTHOURS with Number of hours fall under - 06:00
Page Loading Time
Page Loading Time  I have a application which has a tab type structure in the JSP front end and Java backend. On clicking a tab, it opens the list..., a page opens(ajax calls to server) which has atleast two iframes in it. I want
excel report fro jsp mysql
excel report fro jsp mysql  Dear Sir, I am facing some problem while generating excel report form mysql database using jsp code. With the help from your site, I can able to generate excel file for all data types other than blob
JSP hide and show tables
JSP hide and show tables In this tutorial, you will learn how to hide and show html tables using javascript in jsp. Here is an example of simple jsp code..., table will be visible with all the data. Example: <%@page language
How to show data from database in textbox in jsp
How to show data from database in textbox in jsp   How to show data from database in textbox in jsp   Here is an example that retrieve the particular record from the database and display it in textbox using JSP. <
jsp page
jsp page  <%@page contentType="text/html" pageEncoding="UTF-8"%>...;%@page import="java.sql.Statement"%> <%@page import="java.sql.DriverManager"%> <%@page import="java.sql.Connection"%> <%@page import
how to print the server time
how to print the server time  how to print the server time in jsp and update time in fix interval
ModuleNotFoundError: No module named 'odoo10-addon-hr-attendance-report-theoretical-time'
;odoo10-addon-hr-attendance-report-theoretical-time' error? Thanks  ... can install odoo10-addon-hr-attendance-report-theoretical-time python with following command: pip install odoo10-addon-hr-attendance-report-theoretical-time
ModuleNotFoundError: No module named 'odoo10-addon-hr-attendance-report-theoretical-time'
;odoo10-addon-hr-attendance-report-theoretical-time' error? Thanks  ... can install odoo10-addon-hr-attendance-report-theoretical-time python with following command: pip install odoo10-addon-hr-attendance-report-theoretical-time
ModuleNotFoundError: No module named 'odoo11-addon-hr-attendance-report-theoretical-time'
;odoo11-addon-hr-attendance-report-theoretical-time' error? Thanks  ... can install odoo11-addon-hr-attendance-report-theoretical-time python with following command: pip install odoo11-addon-hr-attendance-report-theoretical-time

Ads