Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Lib Dynamic Data Source from Resource Property(How to dynamically bind db url, user, pass from property file)
Lib Dynamic Data Source from Resource Property [message #640660] Mon, 22 November 2010 17:54 Go to next message
Mike is currently offline MikeFriend
Messages: 3
Registered: July 2009
Junior Member
I'm using Eclipse-Helios 20100617-1415 and BIRT 2.6.1. I've also tried Ganymede and BIRT 2.3.1.

I have what I thought would be among the simplest of cases for dynamically providing the db url, user, and password from a resource property file. But it isn't working.

In my local.properties file I have something like:
database_url=jdbc:oracle:thin:@localhost:1521:xe
database_user=dbuser
database_pass=u8sjsmd8YY==

And from the library file, I have a data source defined on the Property Binding screen as:
JDBC Driver Class: oracle.jdbc.OracleDriver
JDBC Driver URL: params["database_url"]
User Name: params["database_user"]
Password: params["database_pass"]

It works fine if I create a report and use the library if I define the url, user, and password explicitly.

Thank you for your help.
Re: Lib Dynamic Data Source from Resource Property [message #640706 is a reply to message #640660] Mon, 22 November 2010 21:22 Go to previous messageGo to next message
Mike is currently offline MikeFriend
Messages: 3
Registered: July 2009
Junior Member
Blast, I see that I made assumptions about the binding of local property values from resource files to "params." But I've not yet been able to work out grabbing the resource file values and using them for data source connectivity. And I see that many others have struggled too.

Does anyone have that working?
Re: Lib Dynamic Data Source from Resource Property [message #640741 is a reply to message #640706] Mon, 22 November 2010 23:39 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike,

In the beforeOpen script of the datasource you could set the values
dynamically eg

this.setExtensionProperty("odaURL","mydburl");
this.setExtensionProperty("odaUser", "MyUserName");

You could probably get these values from the cp by doing something like:
importPackage( Packages.java.util );
importPackage( Packages.java.lang );
importPackage( Packages.java.io);
configProps = new Properties();
instr =
reportContext.getApplicationClassLoader().getResource("myconnprops.properties ").openStream();
configProps.load(instr);
instr.close();
this.setExtensionProperty("odaUser", configProps.getProperty("username"));

but why not just use a connection profile which does all this for you?
Take a look at this message:
http://www.eclipse.org/forums/index.php?t=msg&goto=51374 3&#msg_513743


Jason

On 11/22/2010 4:22 PM, Mike wrote:
> Blast, I see that I made assumptions about the binding of local property
> values from resource files to "params." But I've not yet been able to
> work out grabbing the resource file values and using them for data
> source connectivity. And I see that many others have struggled too.
>
> Does anyone have that working?
Re: Lib Dynamic Data Source from Resource Property [message #640899 is a reply to message #640741] Tue, 23 November 2010 13:37 Go to previous messageGo to next message
Mike is currently offline MikeFriend
Messages: 3
Registered: July 2009
Junior Member
Jason - thank you for the response and some direction. I did go through the exercise in the link and create a connection profile in a library, and I was able to use that in a report. But let me step back and give you our "requirements" or desires:

~ We do not want to modify the report file or the library at all across various environments (local dev workstation, development server, QA server, production server).

~ We want the library to be able to "look up" or otherwise determine which environment it's in, and use appropriate connect info to the DB.

This last point is the sticky one for now. There are a couple ways of doing that - but we prefer to define the connect info directly in a prop file (or similar). Prop files are plain text, we can have them setup differently in each environment, and we can edit them very easily without bringing up an IDE or engaging in other cumbersome deployment activities.

Relatedly, we prefer NOT to have a single property "env=prod" wherein there is code in the library to check for "env=prod" and then set attributes dynamically within. This places too much configuration information within a file that must be tested and redeployed should anything change (such as DB server name, port, etc.).

Basically, we want to optimize for simplicity in configuration as our reports migrate through the deployment cycles on their way to live/production service.

It does not seem that connection profiles meet that kind of simplicity (the data file is not plain text) - but I may be (as I've done before!) missing something. Smile

Thank you again and humbly request for any further help and direction.
Re: Lib Dynamic Data Source from Resource Property [message #640918 is a reply to message #640899] Tue, 23 November 2010 14:37 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike,

The connection profile can be plain text or encrypted and does not need
to be in a library although the datasource that uses it can be. It was
designed for the very scenario you describe. You can setup a beforeOpen
script to use the connection profile that is deployed in the resource
folder which can be different for every environment. For example assume
I have a connection profile named mysqlclassic.txt and I put it in the
resource folder of the deployed environment I can set the store path like:

myresourcefolder = reportContext.getDesignHandle().getResourceFolder()
this.setExtensionProperty("OdaConnProfileStorePath",
myresourcefolder+"/mysqlclassic.txt");

If this is the development environment and the QA environment has a
mysqlclassic.txt located in its resource folder the report will run with
no changes assuming the mysqlclassic.txt contains valid connection
properties.

When creating the connection profile make sure to un-check Encrypt file
content to store the profile as text.

Jason

On 11/23/2010 8:37 AM, Mike wrote:
> Jason - thank you for the response and some direction. I did go through
> the exercise in the link and create a connection profile in a library,
> and I was able to use that in a report. But let me step back and give
> you our "requirements" or desires:
>
> ~ We do not want to modify the report file or the library at all across
> various environments (local dev workstation, development server, QA
> server, production server).
>
> ~ We want the library to be able to "look up" or otherwise determine
> which environment it's in, and use appropriate connect info to the DB.
>
> This last point is the sticky one for now. There are a couple ways of
> doing that - but we prefer to define the connect info directly in a prop
> file (or similar). Prop files are plain text, we can have them setup
> differently in each environment, and we can edit them very easily
> without bringing up an IDE or engaging in other cumbersome deployment
> activities.
>
> Relatedly, we prefer NOT to have a single property "env=prod" wherein
> there is code in the library to check for "env=prod" and then set
> attributes dynamically within. This places too much configuration
> information within a file that must be tested and redeployed should
> anything change (such as DB server name, port, etc.).
>
> Basically, we want to optimize for simplicity in configuration as our
> reports migrate through the deployment cycles on their way to
> live/production service.
>
> It does not seem that connection profiles meet that kind of simplicity
> (the data file is not plain text) - but I may be (as I've done before!)
> missing something. :)
>
> Thank you again and humbly request for any further help and direction.
Previous Topic:Problems with page break
Next Topic:data loss while exporting pdf
Goto Forum:
  


Current Time: Tue Apr 16 17:28:29 GMT 2024

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

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

Back to the top