Announcement Announcement Module
Collapse
No announcement yet.
A question about JasperReport in Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • A question about JasperReport in Spring

    If I have a *.jasper file which created by ireport, and it already contain the query language inside. I only want to use Spring controller to generate the PDF file. When I use ireport to create & compile &generate, the report pdf file is successfully generated with field value from database rendered in report.

    But, now, if I move it to Spring controller to generate the report (I use standard Spring+JasperReport framework), since it is a database report, the query language is insdie the *.jrxml file, so, I do not have any datasource in java, the report directly access database. When I run, the report generated from controller is always empty, I think it is because there is no CONNECTION object given by controller, the database connection can not open, so that the *.jasper file can not access database.

    My question is how to open connection in side my controller for the Jasper file to access database.

    PS:
    To make my question more clear, I describe it in another way:

    for example, if the report is not a database report, which means there is no sql qurey language inside the *.jrxml file, Inside spring Controller, the Java code create a datasource and use the following way to give the datasource to report file:
    Code:
    model.put("JRDataSource", dataSource);
    return new ModelAndView("report", model);
    But now, I use a database report with sql query language insdie *.jrxml file, in order to make the report file be able to access to database, My Spring controller need to open the connection for the Jasper report, like the controller can give a datasource to the report file above. My question is , how can the spring controller Give/Open a connection for the database report file, inorder to enable the report file to execute the sql query language inside *.jrxml
    Last edited by mellon; Apr 1st, 2009, 08:46 AM.

  • #2
    Anyone can help? Appreciate.

    Comment


    • #3
      JREmptyDataSource... in the Jasper documentation say taht you always have to have an datasource, if you don need a database connection , the empty datasource will work good luck...

      Comment


      • #4
        Hello mellon

        When I use ireport to create & compile &generate, the report pdf file is successfully generated with field value from database rendered in report.
        Thats right, Normally in IReport I use a jdbc configuration to access the db


        My question is , how can the spring controller Give/Open a connection for the database report file, inorder to enable the report file to execute the sql query language inside *.jrxml
        I suggest read this
        http://java.dzone.com/articles/sprin...pring-web-flow
        carefully

        HTH

        Regards

        Comment

        Working...
        X