PDA

View Full Version : Access Query and DataSet inside a report



atkien
09-30-2010, 04:27 PM
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

anupjoshi7
10-01-2010, 04:45 AM
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 .

Taqua
10-01-2010, 07:37 AM
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 ;)

atkien
10-01-2010, 03:03 PM
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

Taqua
10-01-2010, 04:20 PM
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.