Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Passing a JDBC connection to standalone Birt App
PHelgren
I have a requirement that the connection information that is part of the original report design be "overridden" after deployment. In Jasper, all I have to do is pass the created JDBC connection to the engine. That is it. I'd like to reuse the code that creates the connection and then pass that connection to my BIRT report. What I haven't been able to find is a *simple* way to accomplish this in BIRT.
The reality is that the reports could be created by a developer on a completely different system and then deployed. If I can find a way just to pass the connection object to BIRT (like I can with Jasper) that would greatly simplify the process of running them on the target system.
I have looked at various examples but I haven't found anything similar to a "pass the connection object" solution. I am using BIRT 2.3 and the report runs currently in a standalone Java app. I am sure this is simple but I haven't stumbled across a solution.
What would you suggest?
Thanks!
Find more posts tagged with
Comments
cypherdj
Hi PHelgren,<br />
<br />
have you looked into using a JNDI connection?<br />
<br />
<a class='bbc_url' href='
http://wiki.eclipse.org/index.php/BIRT/FAQ/Data_Access#Q:_How_can_I_pass_a_connection_object_to_BIRT.3F'>BIRT/FAQ/Data
Access - Eclipsepedia</a><br />
<br />
All you would need to do is to declare the jdbc connection in the application server hosting your BIRT deployment, and use the JNDI property of your data source.<br />
<br />
Let me know if this does not answer your question,<br />
Rgds,<br />
Cedric
PHelgren
Thanks Cedric,
This isn't a web app running inside Tomcat. It is a standalone Java app. If it was running inside Tomcat I might take the JNDI approach but in this case I can't head that direction.
PHelgren
This ended up being much easier than I thought. The difficulty was in FINDING the solution, not an easy task.
If you are running BIRT 2.3.1 (it didn't seem to work in 2.3.0) then add this to your code:
task.getAppContext().put("OdaJDBCDriverPassInConnection", pConnection);
This adds a connection that is passed in (pConnection in this case) to the context and is used instead of the connection defined in the report.
Simple code, hard to find answer.