• Post Reply Bookmark Topic Watch Topic
  • New Topic

JasperReport : Dynamic SQL Query to inside <queryString> Tag of jrxml file  RSS feed

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

The below is part of my sample MyReport.Jrxml File .
Here as you can see the sql query is static .




How can i make it dynamic , so that i want to pass this value dynamically from my Java Program .
Please guide me .
Please tell me what should be appended inside the queryString Tag so to make it dynamic ??

Thanks .
 
bikashmca kr
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use parameter for this purpose, like for ACTUAL_DATE, following is the syntax.

in sql query you can write, you need to create input control in the jasperserver also while uploading this jrxml.

where date = $P{ACTUAL_DATE}

<parameter name="ACTUAL_DATE" class="java.util.Date">
<defaultValueExpression><![CDATA[(new java.util.Date())]]></defaultValueExpression>
</parameter>

<parameter name="STRING_PARAMETER" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
 
guntur reddy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
se this example it is usefull

The only change we need to make on the JRXML template is to remove the <queryString> element.
To fill the report, we need to execute a database query in our Java code, and pass the query results to the report in a datasource, as can be seen in the following example:



I think it is useful

Thanks
venu
 
Andras Lakos
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Hello Guys ! Please, could you show us the class DbReportDSFill
 
rafael taveras
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Made the same code, but i have this error, please helpme:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:492)
at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:448)

i have a proyect form 2014 and this worked find years ago.. now dont.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!