Jasper Report generation

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperRunManager;
public class Reporter {
     public void generateReport() {
          System.out.println("Report Method");
          Map parameters = new HashMap();
          parameters.put("where", "");
          FileOutputStream fos = null;
          Connection c = null;
          try {
               System.out.println("Getting Conncetion");
               Class.forName("oracle.jdbc.driver.OracleDriver");
               c = DriverManager.getConnection(
                         "jdbc:oracle:thin:@10.237.51.5:1521:hrtfddev",
                         "PORTAL_TEST", "PORTAL_TEST");
               System.out.println("Got Connection");
          } catch (ClassNotFoundException e1) {
                         e1.printStackTrace();
          } catch (Exception e) {
               System.out.println("Exception=====");
          try {
               System.out.println("1");
                                   InputStream in = this.getClass().getClassLoader()
                         .getResourceAsStream("newown.jasper");
               System.out.println("3");
               System.out.println("inputstream     " + in);
               System.out.println("expoted report to PDF");
                              byte b[] = JasperRunManager.runReportToPdf(in, parameters, c);
               System.out.println("file output stream started");
               fos = new FileOutputStream("D:/report.pdf");
               System.out.println("the file output stream is " + fos);
               fos.write(b);
               fos.close();
          } catch (FileNotFoundException e) {
               // TODO Auto-generated catch block
               System.out.println("FILE NOT FOUND");
               e.printStackTrace();
          } catch (IOException e) {
               // TODO: handle exception
               System.out.println("IOException");
          } catch (JRException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
               System.out.println("large JRException");
am new to jasper...
problem with this code.. no compilation error nor runtime time error..
It generated a .pdf file but that file is empty... can any one help me out..
Expecting ur replies guys

does this work when you're NOT trying to do it from code? IE: have you used a jasper tool to try this? iReport is free, and there are others that have free trials. They allow you to define the connection parameters and preview the report in the UI. If the PDF comes out with NOTHING, i have to wonder if your query is returning anything. Is there static text in the report? A title? if not, make some static text and see if that is coming out. if it is, your problem seems like the query. IF it's not, I'm not sure :)

Similar Messages

  • Error in Jasper Report Generation

    Hi,
    I generated Jasper Report.
    Jar File Used:
    1)classes12
    2)commons-beanutils-1.5
    3)commons-collections-2.1
    4)commons-digester-1.7
    5)commons-logging-1.0.2
    6)jasperreports-1.2.1
    7)org.eclipse.jdt.core.manipulation_1.0.0.v20060605-1400
    8)org.eclipse.jdt.core_3.2.0.v_671
    Jdk Used
    JDK 1.5
    Java File:
    import java.util.HashMap;
    import net.sf.jasperreports.engine.JREmptyDataSource;
    import net.sf.jasperreports.engine.JRException;
    import net.sf.jasperreports.engine.JasperCompileManager;
    import net.sf.jasperreports.engine.JasperExportManager;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.JasperReport;
         public class LineDisplay {
         public static void main(String[] args) {
         JasperReport jasperReport;
         JasperPrint jasperPrint;
         try {
         jasperReport = JasperCompileManager.compileReport("F:\\SampleProject\\Jasperreport\\WEB-INF\\src\\com\\zylog\\Sample.jrxml");
         jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), new JREmptyDataSource());
         JasperExportManager.exportReportToPdfFile(jasperPrint, "c:\\firstReport.pdf");
         } catch (JRException e) {
         e.printStackTrace();
    I succesfully generated Jasper Report.But My client faced the following Exception as,
    java.io.FileNotFoundException: F:\MBSWorkspace\JasperReport\Sample_1252478220359_232342.class (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at net.sf.jasperreports.engine.util.JRLoader.loadBytes(JRLoader.java:272)
    at net.sf.jasperreports.engine.design.JRAbstractClassCompiler.compileUnits(JRAbstractClassCompiler.java:73)
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:190)
    at net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(JRDefaultCompiler.java:131)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:211)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:144)
    at com.zylog.jasper.Sample.main(Sample.java:18)
    NESTED BY :My Client Used JDK 1.6..
    I dont know why he got a such problem..Help anyone to solve it..

    Deepa_05 wrote:
    What do you mean?They mean that every time something doesn't work for you, you just post it here and act all helpless, rather than try and solve it yourself. Do you not have any idea what the error might be telling you?

  • Jasper reports generation

    Hi, All
    Iam already generated pdf and excel reports.My problemis that i have to generate reports between the startDate to endDate.I have two inputdate calenders one for startDate and another for endDate.Iam using JSF.how can i generate pz anybody help.
    Thanks on advance

    You should probably find a forum that deals with Jasper Reports, this one is not it.

  • Issue with ADF Application Report Generation

    1) We are developing the web-base ERP application we are using technology as follows
    a) Operating System Red Hat Enterprise Linux4.
    b) Application Server Oracle Application Server 10.1.3
    c) Oracle ADF is the frame work
    d) Jasper reports (iReport 3.0.0) as report generation tool.
    While generating larger reports using iReport3.0.0 Tool i,e., contains more than 20,000 records the query while executed in Sqlplus takes less than a minute, but while the report is run it takes more time leading to time out and the pdf file is not generated. The error shown on the screen is “the web server unable to process the given request”
    The session time-out is 5 minutes. Please help us to tackle this issue since most of the reports are summarized reports and contain large transactional data and is critical reports.
    You may also suggest other web based report tools which help us generate large reports in PDF and/or text formats.
    By
    PRABEETHSOY P
    Edited by: prabeethsoy on Jun 26, 2009 1:13 AM

    PRABEETHSOY,
    some things come to mind.
    While generating larger reports using iReport3.0.0 Tool i,e., contains more than 20,000 records the query while executed in Sqlplus takes less than a minute, but while the report is run it takes more time leading to time out and the pdf file is not generated.Running a query in sqlplus is totally different from running it in an application. Sqlplus only pumps the results to the screen, whereas the application builds some layers around the data, so that you can navigate through the result. This will cost some time.
    You can try to optimize your strategy working with the data, i.e. running the query in forward only mode and/or omit the usaeg of EO where you know you don't need to change data.
    But in the end you may find that you have to use a different approach to generate the reports: do it asynchrony, meaning that you start the generation on the server, let it finish there (putting the result in a file) and send the finished report to the user in a different request. Do do this you can use a poll component, or you ask the user to come back later (giving him a report number to ask for). Other solution are possible.
    Timo

  • Generating sub reports with XML Datasource in Jasper Report

    Hi ,
    I have a query related to report generation using Jasper Reports. I have managed to generate main report with XML as a datasource but am unable to do so for subreport. I tried serching through Google but in vain. If by chance I've missed out any of the links, i would be grateful for that. Sample code woukd really make my life better.
    Sorry in advance if i 've posted in wrong forum.(if it hurta anyone)

    Hello there,
    I am new to JasperReports and am having a similar problem. Were you able to find out how to do this. Any help is appreciated.
    Thanks in Advance
    Regards
    Sriram

  • Session in Jasper Report

    Hi All,
    I'm currently using Jasper Reports for report generation. I'm currently facing problem in retrieving session objects while generating the report.
    I'm trying to Print a report by exporting it to pdf format. In the jrxml, i include a Sub report which creates a graph. Now in the class which extends the JRDefaultScriptlet when I try to get the session object, it is returning null. Hence I cannot retrieve my session objects to be used while generating report.
    Please reply on how do I proceed with it.

    <textField hyperlinkType="LocalAnchor">
    <reportElement x="0" y="30" width="555" height="30"/>
    <textFieldExpression>
    <![CDATA["Go to summary section."]]>
    </textFieldExpression>
    <hyperlinkAnchorExpression>
    <![CDATA["summary_section"]]>
    </hyperlinkAnchorExpression>
    </textField>where hyperlinkType could be:
    - Reference (Hyperlink points to an external resource) = <hyperlinkReferenceExpression>
    - RemoteAnchor (Hyperlink points to an anchor in an external resource) = <hyperlinkAnchorExpression>
    - RemotePage (Hyperlink points to a page in an external resource)=<hyperlinkPageExpression>
    - LocalAnchor (Hyperlink points to an anchor in the report, defined by the <anchorNameExpression> element.)=<hyperlinkAnchorExpression>
    - LocalPage (Hyperlink points to a page in the current report.)=<hyperlinkPageExpression>
    - None (Used to indicate that the element containing the hyperlinkType attribute is not an anchor (this is
    the default) )
    hth

  • Beginner trying to use Jasper Reports

    Hi,
    I am a beginner in implementing report generation. I want to use Jasper reports to convert my xml to pdf using the ireport plugin in Netbeans
    Presently i have an input xml, i do not want to make an JDBC connection or an database connection, i am using another tool to generate xml output from the database.
    i get my input xml and i want to convert into pdf, is there any way to do that??
    thanks a lot

    You should probably find a forum that deals with Jasper Reports, this one is not it.

  • Database report generation?

    Anyone know of any good java-based database report generation tools that would work in a JSC created application? I'd like both web reporting and print capabilities.
    thanks in advance!
    Paul

    I haven't used any report generation tool with Creator. But I have seen users reporting about using Jasper Reports and JReports along with Creator in this forum.
    - Winston
    http://blogs.sun.com/roller/page/winston?catname=Creator

  • Apex and Jasper Report Integration

    Hi all,
    If someone was interested to try another way for pdf generation from an apex application can try our Report Chunker based on Jasper Report and now avaiable to download on :
    [http://sourceforge.net/projects/reportchunker/]
    The latest release includes an APEX DEMO APPLICATION.
    Any feedback will be welcome.
    Edited by: NeOGeO on 23-set-2008 1.28

    A few points here.
    Documentation:
    You need to state what permissions are required.
    eg create table, create sequence, create trigger, read/write directory.
    You should also mention the authentication method you use.
    Fortunately I could figure that out myself.
    Now bearing in mind I am your typical target audience, I have no knowledge of Jasper reports, and very little knowledge of java and xml. So I'm now stuck as I don't know what to use for the xml layout or how to write my report.
    At least provide an example xml layout, a example report and a link to where the reports cab be obtained.
    If we need to have anything on the system before we start (eg jasper reports) then this should also be stated (including minimum required version)
    Thats it. Unfortunately I can't go any further until I know more.

  • Open vi error for report generation toolkt

    Originally it works fine.
    Now I upgrade to win7, LV9 and office2010.
    To open the old program by 8.6.1, I reinstalled LV 8.6.1 and report generation toolkit.
    But still got the error as attached.
    Any suggestion, thanks.
    Attachments:
    ss.png ‏184 KB

    1. MS Office 2010 is not yet supported, since it's still just a beta. I believe there are couple of changes that Microsoft make, and it could cause a problem.
    2. LabVIEW 8.6.1, and all its toolkit is not supported on Windows 7. This could cause a problkem also.
    In conclusion, you should use LabVIEW 2009, Report Generation Toolkit 2009, Windows 7, and downgrade office to XP, 2003 or 2007.
    More information: http://digital.ni.com/public.nsf/allkb/C9408B9F08D​711E786256F3300701D01

  • Report generation toolkit and signal express user step : problem of closing reference in "Stop" event

    Hi all,
    I'm trying to make a package of Vis to easily make Excel reports with Signal Express. I'm working on LabVIEW 8.2.1.
    I'm using the report generation toolkit, so I build a .llb from my project which contains all the hierarchy of my steps, but also the hierarchy of dynamic VIs called.
    I have made some steps, like "Open Workbook", "Write Data", etc.
    My steps run well, excepts one step : "Close Workbook".
    If my "Close Workbook" step is firing on "Run" Signal Express event, I have no error, so my reference is properly closed.
    But if my "Close Workbook" step is firing on "Stop" Signal Express event, I have an error "1", from "Generate Report Objectrepository.vi".
    I feel that I'm trying to use a reference which has been killed in the "Stop" step...
    I would like to know what exactly do Signal Express on "Stop" event and why my close function does'nt run well.
    Thanks,
    Callahan

    Hi Callahan,
    SignalExpress (SE for short) does the following on the Stop event:
    1. Takes the list of parameters that SE found on your VI's connector pane, and sets the values that the user set from the "Run LabVIEW VI" configuration page, if any.
    2. Then tells the VI that SE is running the Stop event by setting the Enum found on your VI's front panel. This in turn should produce some boolean values telling your VI to execute the Stop case.
    3. The VI is then run, with those values and states.
    4. SE checks to see if any errors where returned.
    5. Since this is the Stop event, SE releases the reference to the VI which it possesses.
    Questions for you would be, is the reference to your Workbook linked to a control on your connector pane, or held in a uninitialized Shift Register. If it's held in a Shift Register, SE would not be aware of it, and would not be able to affect that reference.
    Hope that helps. Feel free to post your LLB if it doesn't.
    Phil

  • Report Generation: New Report.vi

    Running applicaion in development mode works fine.
    After compiling however I get Error 7: Open VI Reference in New Report.vi
    Why am I getting this error?

    Has the version of Office on your machine changed since you installed the Report Generation Toolkit?  The VIs will become broken if the ActiveX interface changes, and this can happen when the Office version changes.  I recommend uninstalling and reinstalling the toolkit.  Also, what version of Report Generation Toolkit are you using?  The latest version is 1.1.1.
    -D
    P.S. - I'm going to respond to your other thread that you started with a link to this one.  Instead of creating multiple messages on the same question, just wait for a response to your initial thread.
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Report Generation Toolkit Error (undefined erro)

    Does anybody know what error -214 682 7864 (0x800A01A8) means when coming from the Report Generation Toolkit.
    I have an app which has been happily ticking over for several weeks, and then this error was generated when attempting to write a table to a spreadsheet. The error was generated all the way down in NIReportGenerationToolkit.lvlib:Excel_Get_range.vi (this is the ActiveX code).
    Any ideas? 
    nrp
    CLA

    nrp wrote:
    I have an app which has been happily ticking over for several weeks, and then this error was generated when attempting to write a table to a spreadsheet.
    Was it the first time you attempted to write the table to that spreadsheet?
    Maybe the error is due to the spreadsheet grown oversize than its limit so that it cant accomodate the table anymore.
    What is the version of MS Office you are using? I think Office 2003 can go only upto 1024 columns...
    - Partha
    LabVIEW - Wires that catch bugs!

  • Report Generation Exe Error

    Hello,
     I am using LV 8.6.1 with the 1.13 report generation toolkit and I am having problems getting my built exe to work.  I am trying to open an excel template and populate it with new data.  I have broke the vi down to just opening excel - opening the template and then fill in some data.  But at this point excel does not open at all.  And naturally everything works fine in the development environment.
    Error Code: -2147352573
    Member not found in NI_ReportgenerationToolkit.lvlib:
    Excel_open_workbook.vi
    NI_Excel.lvclass: new reportsubvi.vi
    I read a few help pages that said to add \vi.lib\utility\NIreport.llb and LVclass directories to the project folder and add them to the always include section of the build.  But no luck so far.
    Side question:  The machine I want to use this on has 8.6.1 Full which does not have the extra excel functions that my developer has.  Is there a way to install the DEV report generation toolkit in the full version?  Then I would not need to build an exe.
    UPDATE:  I just tried the exe on a different machine that has a developer suite installed and it worked fine.  So I guess I need to find out what else I need to add to the build to make it work.
    Message Edited by _Bryan on 06-16-2010 11:58 AM
    Solved!
    Go to Solution.

    There should be some info on this in the KB.
    But first you should make sure that your version of the report generation toolkit actually supports excel 2000 (which is 10 years old)
    That should be in the release notes of the toolkit
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Report-generation vi problem

    On a Windows XP system using the "Text Report Example" vi, the (read) report property node item "TextFont" (stdole.Font) at the beginning of the "Font Style" vi which is a part of the "Set Report Font" vi is returning this error:
    "-1073741819 Unknown System Error in Font Style.vi->Set Report Font.vi->Easy Text Report.vi"
    Any suggestions as to a cause and cure?

    This Knowledge Base from NI's website actually deals with this problem. The fix depends upon whether or not you have the Report Generation Toolkit for LabVIEW. There are fixes for whether or not you have the Toolkit. Hope this helps.
    J.R. Allen

Maybe you are looking for

  • USB devices cause a crash at Lion login screen

    Since I have installed MacOS X Lion I am experiencing regular crashes at the login screen at startup. These crashes occur virtually always when + a USB device that was connected at the previous shutdown is missing at next launch + a USB device that w

  • Adobe Reader & Acrobat 6~9 Group Policy ADM file (only applied once?)

    Hi folks. I created the below ADM template last month based on some of the ones I have seen elsewhere. I import the ADM file to use with Group Policy and make the necessary settings (need to uncheck "Only show policy settings that can be fully manage

  • Album Artwork on iPod question?

    I know that you can import pictures to use as album artwork in iTunes, and I did that for all of the albums that didn't have album artwork pictures. However, when I did that, it would take the songs that I put pictures on there, right off of my iPod.

  • How to reset View Object row state to Unmodified

    Hi, My requirement is as follows. In my home page, I have a table listing master records with links to a master detail page. In this master detail page, the master is displayed in a form, and details in an editable table. There is also a button that

  • Which oracle logo should I attach on my resume?

    I have just now passed the  1z0-051 ORACLE Database 11g: SQL Fundamentals I exam by 67% (60% to pass). Also i am familiar to PL/SQL too. And lastly I have done an internship project on it. Is I am eligible to attach oracle LOGO on my reume? if yes, w