yurish Posted August 24, 2007 Share Posted August 24, 2007 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 More sharing options...
yurish Posted August 27, 2007 Author Share Posted August 27, 2007 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 More sharing options...
csbac Posted August 28, 2007 Share Posted August 28, 2007 Hi!Instead of using a CustomDataSource, maybe you can create a more complex SQL query? (1) Use case Code:select ...,(case when field='Dog' then 'Cat' when field='Cat' then 'Dog' else fieldend) 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. Sebastian Link to comment Share on other sites More sharing options...
szaharia Posted August 28, 2007 Share Posted August 28, 2007 Hi, 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. hth,sanda Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now