Jump to content
We've recently updated our Privacy Statement, available here ×

Passing database query at runtime to report


sukirtha

Recommended Posts

Hi,

I came to know that jasper allows sql query to be passed at runtime during report generation. However I could not obtain any sample to do the same. If any of you have an idea of how to this, please share it here.

My requirement is as follows,

 

Depending on the user's request, the query to be executed for a particular report will change. So I need to pass the sql query only during runtime.

 

Any help will be appreciated. Thanks in advance.

 

Warm Regards,

Sukirtha Joseph

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You can pass the report query string via a parameter:

Code:

<!-- the JRXML -->
<parameter name="Query" isForPrompting="false"/>
<queryString>$P!{Query}</queryString>

<!-- the fill code -->
String query = "select ...";
params.put("Query", query);
JasperFillManager.fillReport(report, params, connection);

 

HTH,

Lucian

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...