Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / April 2005

Tip: Looking for answers? Try searching our database.

Jasper Reports and Java

Thread view: 
Wendy Angulo - 11 Jan 2005 15:06 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.