Hi!
I need to run a report (JasperReport) from Java, but I need to pass some parameters to the database.
I tried this
--------------------------------
double = fatura = 2554;
Map parameters = new HashMap();
parameters.put("NUM_FACTUR", factura);
JasperFillManager.fillReportToFile(fileName, parameters, getConnection());
------------------------------
where factura is the number that I want to see on my report, and NUM_FACTUR is a field from the table of my database.
I tried this, and Itsn't work.
Is there another way to pass paramters?
Is my code fine? or is wrong? Could you fix it?
Can anyone help me, please???????????????
THANKS in advance.!!!!
My email: wendy@decsacr.com
wendyangulo@hotmail.com
Wendy, CR
dar7yl - 11 Jan 2005 20:52 GMT
Wendy, Try
<code>
Double factura = new Double(2554);
parameters.put("NUM_FACTURA", factura); // naming consistancy fix
JasperFillManager.fillReportToFile(fileName, parameters,
getConnection());
</code>
because the fill manager needs an object in the parameter list, and a native
double just won't suffice.
regards,
Dar7yl
> Hi!
>
[quoted text clipped - 25 lines]
>
> Wendy, CR
Wendy Angulo - 12 Jan 2005 15:58 GMT
Hi dar7yl,
Thanks for your help.
I tried this:
=======================
Map parameters = new HashMap();
double factura = new Double(2555);
parameters.put("NUM_FACTUR", factura);
System.err.println("Parámetro: " + parameters);
JasperFillManager.fillReportToFile(fileName, parameters, getConnection());
System.err.println("Filling time : " + (System.currentTimeMillis() - start));
=======================
but don't work. When I export the file.jrprint to pdf, the file.pdf is with all the rows of the database, so it means that code don't respect the parameters.
Actually when I compile the file.java I get this warnig:
-----------------------
jasperlauncher.java:55: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Map
parameters.put("NUM_FACTUR", factura);
^
1 warning
-----------------------
So, I don't know what is it.
What can I do to fix the problem?
THANKS!
dar7yl - 12 Jan 2005 22:28 GMT
> double factura = new Double(2555);
try
Double factura = new Double(2555);
regards,
Dar7yl.
> Hi dar7yl,
>
[quoted text clipped - 28 lines]
>
> THANKS!
Wendy Angulo - 12 Jan 2005 22:52 GMT
I already tried that.
What else I can try?
Remember:
My report works fine, the problem is that it isn't respecting the parameters.
THANKS!
Wendy, CR
dar7yl - 13 Jan 2005 06:35 GMT
>I already tried that.
> What else I can try?
My only suggestion is to try adding a completely new parameter to the
report, and see if that works.
Keep it simple at first.
> Remember:
> My report works fine, the problem is that it isn't respecting the
> parameters.
Perhaps there is a naming or type difference or something.
regards,
Dar7yl
sunxx - 19 Jan 2005 14:28 GMT
111
"Wendy Angulo via JavaKB.com" <forum@JavaKB.com> ????????????
:79d6f947374e496e97864c30f8d463e9@JavaKB.com...
> Hi!
[quoted text clipped - 26 lines]
> --
> Message posted via http://www.javakb.com
Carlus - 01 Apr 2005 04:53 GMT
Hey there....
I was running into this problem as well. Here is the code snippet that
I used. Of course, I typically use iReports to develop the Jasper
Reports, but I am going to give you both ways of doing it.
In iiReports in the SQL you can place a parameter for a field value like so:
select
item_desc,
charge_amt
from
invoice_line_item
where
invoice_id = $P!{INVOICE_NBR}
where Invoice_NBR would be the Key of the Map that you are passing in.
My actual jrxml snippet is:
<queryString><![CDATA[select
item_desc,
charge_amt
from
invoice_line_item
where
invoice_id = $P!{INVOICE_NBR}]]></queryString>
Just replace INVOICE_NBR with your NUM_FACTUR and you should be all set.
Thanks
Carlus
> Hi!
>
[quoted text clipped - 22 lines]
>
> Wendy, CR