Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Using data source to run two queries or create connection using pojo?
kbog
Hi,
I'm new to BIRT and relatively new to JAVA and I'm trying to come up to speed in BIRT. Here is the background for my question. In java I created a standalone program that connects to a database runs two queries to obtain two results and then maps the result sets to two distinct hashmaps and eliminates duplicates between the two hashmaps. I'm now attempting to implement this in BIRT. Here is my question using BIRT's interface can I create a datasource--connection to the database and then use that connection to script the running of the queries/hashmap etc.. Or do I have to leave/make the connection creation in pojo creating java jar file? It would seem like you could create the connection/datasource in BIRT and then script the execution of the queries and processing of the result sets. But I've been unable to find an example of this. So far I see examples for running a simple query data source/data set and linking it to a table field on the report or the discussion moves to scripted data sources--where I assume you make the connection in the pojo creating java code. Thanks in advance for any advice.
Find more posts tagged with
Comments
Hans_vd
Hi Kbog,
Why don't you write one query that does not select the duplicates in the first place?
kbog
Thought about that but it put a bit of a load on the database; other alternative would be to create a stored procedure or a view. But Pulling the data out into two separate hashmaps --at least in testing--seemed to work quicker and afforded greater flexibility for identifying a duplicate. I had one suggestion to pass the connection string information into the java object (pojo) when initializing it from the Birt data set open() method. This is better than hard coding it into the class. But it still seems to me that it'd be possible to create the data source in the Eclipse BIRT designer and then pass the data source to the java class?
mwilliams
Well, you could possibly create your two separate dataSets within BIRT, then, use the data engine API to run your queries to fill your hashmaps. Then, just create your scripted dataSet from these. Here's an example of using the data engine API.
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1542-data-engine-api-to-check-data-set-values/
The other options could be to create your two dataSets, bind a text box to each, at the top of your report, then, fill your hashmaps in each dataSet's onFetch script and then create your scripted set from there.