Jump to content
Changes to the Jaspersoft community edition download ×

How to pass parameters in the query


anshukunal

Recommended Posts

Hi,

 

How to pass parameters in the sql query in the jasper report via java code.

I am attaching codes which i am using.

 

Code:
.jrxml file<parameter name="REPORT_PARAMETERS" class="java.lang.String"/>	<parameter name="REPORT_PARAMETER" class="java.lang.String"/>	<queryString>		<![CDATA[select * from Info_Log where $P{REPORT_PARAMETERS}=$P{REPORT_PARAMETER}]]>	</queryString>This code didn't worked.Then i tried :<![CDATA[select * from Info_Log where $P!{REPORT_PARAMETERS}=$P!{REPORT_PARAMETER}]]>This gave some sql error.I am able to generate the report passing one parameter in sql query but not with 2 parameters at the same time.<![CDATA[select * from Info_Log where NAME=$P{REPORT_PARAMETER}]]>	</queryString>my java code for taking parameters is:Map parameters = new HashMap();    parameters.put ("REPORT_PARAMETERS","reader");    parameters.put("REPORT_PARAMETER","reader1"); JasperPrint jasperPrint = JasperManager.fillReport(jasperReport,parameters, connection);
Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 years later...

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...