Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Multiple Database Connections in BiRT(Is it possible to change Database (multiple) connections in runtime via System Properties.)
Multiple Database Connections in BiRT [message #716475] Wed, 17 August 2011 14:11 Go to next message
Dusan Bratusa is currently offline Dusan BratusaFriend
Messages: 3
Registered: August 2011
Junior Member
Hi,


is it possible to change a Database Connection in BiRT at runtime via for e.g. System Properties.

I've read that I could use Property Bindings on a DataSource but then it would only be possible to change between two databases.
I have multiple environments and it would be really convenient if I could do this via System Properties.

Best Regards,
Dušan
Re: Multiple Database Connections in BiRT [message #716548 is a reply to message #716475] Wed, 17 August 2011 16:17 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

What are you storing the in the System Property?

You can always get a system property using an expression (property
binding) or script in BIRT. Just use something like:


var sysprop = Packages.java.lang.System.getProperty("my.sys.property");

For other options have a look at these posts

http://birtworld.blogspot.com/2005/12/using-supplied-connection-with-birt.html

http://birtworld.blogspot.com/2007/01/birt-connection-pooling-continued.html

Jason


On 8/17/2011 10:11 AM, Du wrote:
> Hi,
>
>
> is it possible to change a Database Connection in BiRT at runtime via
> for e.g. System Properties.
>
> I've read that I could use Property Bindings on a DataSource but then it
> would only be possible to change between two databases. I have multiple
> environments and it would be really convenient if I could do this via
> System Properties.
>
> Best Regards,
> Dušan
Re: Multiple Database Connections in BiRT [message #716568 is a reply to message #716548] Wed, 17 August 2011 17:35 Go to previous messageGo to next message
sam va is currently offline sam vaFriend
Messages: 121
Registered: July 2011
Senior Member
We have similar requirement. We did it in a different way. I am not sure if it suits you.
We loaded the db details into a property file (eg username /pwd / host etc). And in the beforeOpen method of the datasource, we have the following code.

importPackage (Packages.com.pkg1.birt);
this.setExtensionProperty("odaDriverClass", BirtProperties.getDbDriver());
this.setExtensionProperty("odaURL", BirtProperties.getDataMartDBHostString());
this.setExtensionProperty("odaUser", BirtProperties.getDataMartDBUserName());
this.setExtensionProperty("odaPassword", BirtProperties.getDataMartDBPassword());

This way, each env will have a property file with different properties. BirtProperties is a java class, which just reads the property file from the classpath.

For this to run, you need to have the java class and the property file in the classpath of the report.

Thanks
Re: Multiple Database Connections in BiRT [message #716740 is a reply to message #716568] Thu, 18 August 2011 09:33 Go to previous message
Dusan Bratusa is currently offline Dusan BratusaFriend
Messages: 3
Registered: August 2011
Junior Member
Thanks to both of you.

I've used a little from both solutions and it suits my needs.

Best Regards,
Dušan
Previous Topic:BIRT log files
Next Topic:error running report in birt viewer
Goto Forum:
  


Current Time: Fri Apr 19 09:43:40 GMT 2024

Powered by FUDForum. Page generated in 0.02013 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top