Hot questions for Using JasperReports in postgresql

Question:

I have a query which is creating array of double values returned.

 SELECT array_agg(price) rm FROM product;

When I am running this query in Postgres Shell I am getting output as expected,

-[ RECORD 1 ]--+----------------------
rm             | {79.33,49}

But when I am running the same in Jasper Report I am getting output as

-[ RECORD 1 ]--+----------------------
rm             | {79.3299999999,49}

Is it the issue of Postgres JDBC driver or something is missing my query?


Answer:

What you need is setting the extra_float_digits PostgreSQL variable to 0 for the connection.

If you create the connection yourself, you can directly do connection.createStatement().execute("set extra_float_digits to 0")

If you use a connection pool, you can highjack that validation query to do select set_config('extra_float_digits', '0', false)

And if none of the above apply, you can do it directly in your query as in select set_config('extra_float_digits', '0', false), array_agg(price) rm from product

Question:

I'm trying to use parameters in Jasper Reports but I'm getting some difficult using list, more precisely Integer List.

I have a Postgres procedure that receives an integer array as parameter like this query select * from function_x(array[n1,n2,n3]). But I don't know how send this values as a Postgres Array.

I already set the param to Multi Select Query in JasperServer.

Can someone help me? Thanks a lot...


Answer:

Just added MacGyver:

<queryString>
        <![CDATA[select * from function_x(array$P!{PARAMETER})]]>
</queryString>

Postgres accept array[] or {} as array values and the problem is that the Jasper was trying to send [n1,n2,n3] (string) so what I done was concatenate array with [].

That solved my problem...

Question:

I am using postgresql as database. In db i have one column which contains xml with language codes. I want to parse that xml and get value trough the report language.

select o.name,o.price from bookdefinations o This o.name contains that xml value:

<?xml version="1.0" encoding="UTF-8"?>
<values>
    <en-us>en value</en-us>
    <es>es value</es>
    <ru>ru value</ru>
    <tr>tr value</tr>
</values>

Can i parse this with jasper's expressions or can i parse while selecting from db (i dont have any idea how to get report language in select query and parse xml in select)


Answer:

There is a xmldatasource for jasperreport, you can do a subreport and send the blob to that subreport as an xmldatasource, then you can parse the xml in the subreport and show the content, I'm not sure if you want to show the values or the entire xml, if it is a report I guess you should show the values in a pretty way I mean not as xml, check this link

http://jasperreports.sourceforge.net/sample.reference/xmldatasource/