Jump to content
Changes to the Jaspersoft community edition download ×

Help on replacing


Recommended Posts

Hi! I have such question:


I have database with some kind of data. Through java i'm executing SQL select and getting it. In report i need to put the translation of this data. For example: In database i have "Cat" and in report i need to have it like "Dog". How can i do it?


I tried to make a list of all data, which is tooked from database and putting it in parameters, replacing with view, that i need, in my report, but then i saw, that i can put each parameter only once. Next time parameter is re-written with new value. Can anyone help me?

Post edited by: yurish, at: 2007/08/24 11:09

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Trying to generate CustomDataSource, but still can't get an idea on how to get it used with my app.


JasperFillManager.fillreport is using as parameters (file, parameters, connection). How can i get my CustomDataSource as connection? CustomDataSource is a class, which generates Object[][] from database.

Link to comment
Share on other sites


Instead of using a CustomDataSource, maybe you can create a more complex SQL query?


(1) Use case


select ...,
when field='Dog' then 'Cat'
when field='Cat' then 'Dog'
else field
end) as field_changed, ... from ....


(2) use a lookup table


Maybe this is easier to use than a custom data source? Of course, it requiers the "translation" to be known in advance.



Link to comment
Share on other sites



If you are talking about a large amount of data, and if it's possible to alter your database by creating a new table, then another possibility might be to create a dictionary table, containing all data intended to be replaced, and the correspondent replacement values. Then modify your query in order to get replacement data from the dictionary table, instead of the original table.




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