Results 1 to 10 of 10
Like Tree1Likes
  • 1 Post By SurfMan

Thread: Problem with generating reports using java

  1. #1
    murugaa06 is offline Member
    Join Date
    Jun 2014
    Posts
    3
    Rep Power
    0

    Default Problem with generating reports using java

    Hi friends, I have a problem in generating reports using java code. I created a report using iReport 5.5.0 with MySql Database connection. In iReports, it shows the correct output while previewing it. Then i copied my .jrxml file and pasted it into my netbeans project folder(..sample/web/WEB-INF/sample.jrxml) and then i added the required jar files in my project's library folder. i am generating the report in netbeans using jsp and servlet. THE REPORT IS GENERATING AND SAVED SUCCESSFULLY IN MY DESKTOP. BUT IT DOESN'T GENERATE THE REPORT FOR FIRST RESULT. For Example.., if i generating report based on a particular date. After executing the query, it returns 4 results. So it has to create the reports in 4 pages. But it generates the report for last 3 pages only. It doesn't generate the report for first page. I have attached my .jrxml file servlet file for your reference. Please help me to solve this problem...

    Thanks in advance...
    Attached Files Attached Files

  2. #2
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    450
    Rep Power
    6

    Default Re: Problem with generating reports using java

    THE REPORT IS GENERATING AND SAVED SUCCESSFULLY IN MY DESKTOP. BUT IT DOESN'T GENERATE THE REPORT FOR FIRST RESULT
    I dont know what you are saying about. Please make sure that your report is working fine in your local machine.
    Mak
    (Living @ Virtual World)

  3. #3
    murugaa06 is offline Member
    Join Date
    Jun 2014
    Posts
    3
    Rep Power
    0

    Default Re: Problem with generating reports using java

    Quote Originally Posted by makpandian View Post
    I dont know what you are saying about. Please make sure that your report is working fine in your local machine.
    Thanks for your reply...

    Yes... Reports working fine in my local machine... but my problem is that the report is not generated completely... If the database returns 4 results means, the report was generated for 3 results only... The report was not generated for the first result... This is my problem... How can i sole this problem...??? :(

    Thanks again...

  4. #4
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    450
    Rep Power
    6

    Default Re: Problem with generating reports using java

    Quite weired.

    Did you try debugging mechanisams? If not, that may help to figure out the issue
    Mak
    (Living @ Virtual World)

  5. #5
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: Problem with generating reports using java

    Probably an extra ResultSet.next() call...

    This example is wrong and will skip the first record:
    Java Code:
    ResultSet rs = statement.executeQuery();
    if ( rs.next() ) {
       while (rs.next() ) {
          //do something with the records here
       }
    }
    As you can see this example calls next() twice, effectively discarding the first record.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  6. #6
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    450
    Rep Power
    6

    Default Re: Problem with generating reports using java

    @SurfMan

    Good catch. Awesome :-)
    Mak
    (Living @ Virtual World)

  7. #7
    murugaa06 is offline Member
    Join Date
    Jun 2014
    Posts
    3
    Rep Power
    0

    Default Re: Problem with generating reports using java

    Quote Originally Posted by SurfMan View Post
    Probably an extra ResultSet.next() call...

    This example is wrong and will skip the first record:
    Java Code:
    ResultSet rs = statement.executeQuery();
    if ( rs.next() ) {
       while (rs.next() ) {
          //do something with the records here
       }
    }
    As you can see this example calls next() twice, effectively discarding the first record.
    Thank you for your time.

    As per your suggestion i checked the coding. I dont have two next() statements inside the coding. The problem still persists. Please go through the attached files for your reference.

    Thanks again.

  8. #8
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,049
    Rep Power
    20

    Default Re: Problem with generating reports using java

    Many people don't like to use, or can't access, attached files.
    Post the relevant code here (wrapped in code tags) and you are more likely to get someone to look at it.
    By relevant, in your case that would be the code that loops over the result set and adds objects to whatever array model you have, and any other code that may or may not modify this array before it gets handed to the reporting tool.

    Also, you might want to show exactly how (in your code) you determine that the result set has more rows than are ending up in your report.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: Problem with generating reports using java

    Your code has the following:
    Java Code:
    rs3=stmt1.executeQuery(sql);
    if(rs3.next()){
       obj = new JRResultSetDataSource(rs3);
       ...
    }
    I got a hunch you shouldn't be doing the rs.next(), but just pass the ResultSet in as-is. The JRResultSetDataSource will probably take care of the "no record" situation. I never used Jasper before, so it's a wild guess...
    Tolls likes this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  10. #10
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,049
    Rep Power
    20

    Default Re: Problem with generating reports using java

    Yep.
    That's just a wrapper around the ResultSet which Jasper then uses to produce the report.
    Jasper handles all iteration over the ResultSet.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Problem generating a runnable .jar file
    By GeCe in forum Java Applets
    Replies: 24
    Last Post: 06-30-2014, 04:20 PM
  2. Replies: 0
    Last Post: 04-09-2012, 07:22 PM
  3. Generating Reports in java
    By sandeshyadav in forum AWT / Swing
    Replies: 1
    Last Post: 02-27-2012, 11:52 PM
  4. Annoying Generating Cookies files problem
    By Burglar_Cat in forum Java Servlet
    Replies: 3
    Last Post: 05-11-2010, 01:04 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •