Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Access Query and DataSet inside a report

  1. #1
    Join Date
    Aug 2010
    Posts
    10

    Default Access Query and DataSet inside a report

    Hi All,

    I have a report designed in version 3.6. In that report, I created a query and connection of mySql inside this report (by Report designer). I have a Java class to load report. My question is there is any ways to use a database connection (from Java class) and run that query (inside a report) to create a dataset for report?

    Thanks,

    KV

  2. #2
    Join Date
    May 2010
    Posts
    133

    Smile

    YOu can achieve this by using advance jdbc(custom).
    where you have to initialize a string paramter in a report and pass your custom query from it .

  3. #3
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    If you have the connection defined and it runs in PRD, then you can execute that same report in your own java code by just running it (see the SDK examples on how to run a report). The reporting engine will then use your JDBC definition in the report to connect to the database and queries the data for you. There is no manual work needed by you.

    But of course: Make sure you do have the MySQL JDBC driver on your classpath as well as all required jars for the reporting engine. If you see ClassNotFoundExceptions you dont have them all
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  4. #4
    Join Date
    Aug 2010
    Posts
    10

    Default

    Hi Tauqa,

    Thanks for your reply. COuld you tell me how could I access a designed by using database connection and query from java? What do I need to do?

    Thanks,

    KV

  5. #5
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    What are you trying to achieve? The reporting engine will do the querying - you dont have to do anything.

    If you want to access the datasources, then you can find them on the master-report and on the subreports. Look at the javadoc or sources and you will see a getDataFactory() method which returns the various datasources. Note that a report can have multiple datasources - which one is used is decided by the query-string contained in the report. Parameter may fire their own queries, so do subreports.

    This way you can access the *definition*, but it does not allow you to control how the query is fired. For that you have to provide your own datasources.

    Alternatively you can use either the scripted datasource to call your classes or use the "External datasource" on the report and pass a TableModel into the report. Note that this does not work well with parameters, as you have to provide the data before the parameters are queried.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

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
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.