Jump to content
We've recently updated our Privacy Statement, available here ×

JRResultSetDataSource..


2005 IR Help

Recommended Posts

By: Gopalakrishnan - gopkrish3

JRResultSetDataSource..

2004-07-14 22:00

Hai

I created an employee detail report that accepts Employee Name as parameter. My querystring looks like this

 

<queryString><![CDATA[select * from EMP where ENAME=$P{Empname}]]></queryString>

 

I tested the example by passing java.sql.Connection, to fillReport() method which works fine and gets the details only for the particular employee.

 

I tried the same example by passing JRResultSetDataSource (where resultset contains details for all the employees), but it displayes the details of all the employees instead of one employee, which I passed. Why the query condition failed?

 

With out the setting restriction to the resultset (i.e by putting where condition while getting resultset) is it possible to achieve the restriction on report

 

 

Thanks in Advance

T.Gopalakrishnan

 

 

 

 

By: C-Box - c-box

RE: JRResultSetDataSource..

2004-07-14 22:56

I guess it can't work like you want.... because a JRResultSetDataSource is also a kind of CustomDataSource and if you use any form of JRDataSource (e.g. JRTabeleModelDataSource, JRBeanArrayDataSource, etc...) then you have to fill the datasource JUST with the records the report should show. The query string doesn't have any influence towards the passed datasource. It's just used for direct database-connection. (AFAIK - correct me Teodord or Chuck if I'm wrong)

If you want to use a custom DataSource as base for your reports and you want to filter out just some data out of it and not all records, then you have to write your own class (implements JRRewindableDataSource) that has filter-capabilities. (So I've done... I created a JRFilterableDataSource where I can pass a FilterField and a FilterValue in some public attributes and check within the internal "next-method" of that class if the current record fullfilles the filtercriteria.)

 

hth

C-Box

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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