Jump to content
JasperReports Library 7.0 is now available ×

Sending query thru Map from application


tanvirtonu

Recommended Posts

How to send query thru Map from java application.I did the the following-

Code:

HashMap <String,String> map=new HashMap<String,String>()
map.put("Sql","Select * from loan where loan_id=1"«»);
JasperPrint jasperPrint = JasperFillManager.fillReport(reportFile, map, jdbcConnection);
JasperViewer.viewReport(jasperPrint);

And I also set $P!{Sql} in report query and made a parameter name- Sql, type- String. Will it work

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

No it wont. You need to manualy create the fields in the report. The fields will not be generated automatically by Jasper when you run the report. So what will happen is your SQL will probaly run then you will get an error because the report wont know what to do with your columns.

 

What I've done is manually created the fields and passed a query with a defined number of fields.

 

ie "Select col1, col2, col3 from table where some condition"

Link to comment
Share on other sites

Brother first thing is dat whether u agree that my code is right or not.If my coding is ok, then can I just make a query -"Select * from tablename" in iReport and let my code/application choose which condition to use.I mean-can I use-"Select * from tablename" in ireport query and compile it, and use "Select * from where condition" in my application code.Will it work.Bcos this way the report is getting all the coloumns but depending upon the condition in application, it will fill it accordingly.
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...