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)
Problems with data source
ostrich
Unfortunely I have no access to the production database. So I am searching a way to get the connection information from a properties file. I really hope someone can tell me how to do this.
Find more posts tagged with
Comments
mwilliams
Hi ostrich,
Can you explain your situation more? What kind of database is it? What are your issues with connecting to it? What kind of dataSource are you using? etc. Thanks.
ostrich
I am developing and testing on my machine with my own database (Oracle) because I don't have access to the database of the production system.
My idea was to write the db url, user name and password in a properties file and read them from there for my report. So I think it would be possible to test the reports on my machine and deploy them to the production system.
bhanley
Before you migrate your report off of your development machine, take a look at the data source you are using to test the report against your local instance. The following steps will make your report accommodate all the different servers/instances you may have to migrate through (Dev, Test, QA, etc...)
1) Add a hidden parameter to your report for each element of the connection you want to make dynamic. You may even want to leave these parameters as "public" (not hidden) as you first test this out as changing the values at run time will be easier. Give these parameters default values to match your development instance to ease your local development.
2) Double-click on the Data Source to open in for editing. You will see a "Property Binding" category on the left of the window. Here you will find all the different connection details you can abstract and populate via the hidden parameters you created in Step 1.
-- Driver Class
-- Driver URL
-- User Name
-- Password
-- JNDI URL
-- Connection Profile Name
-- Connection Profile Store URL
3) Use the expression editor (the button to the right of the text box for each property) to bind the property to your hidden parameter.
Then you can modify the hidden parameters as you need to in order to test in any environment you require.
Good Luck.
--Brian
ostrich
Thank you very much. Your explanations helped my to solve my problem
PraveenCh
Hi bhanley,
I am praveen. I am using Birt Engine in my application. But there is a problem with datasource. I have 8 locations with 8 datasources. So,based on location,I have to point to exact datasource.In every .rptdesign file I am loading a .rptlibrary file like this:
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="DataSource" id="3976"
extends="Library.DataSource"/>
In the above tag the “extends” attribute contains libraryfilename.datasourcename.
In my .rptlibrary I am using property bindings like this:
<list-property name="propertyBindings">
<structure>
<property name="name">odaDriverClass</property>
<property name="id">5</property>
</structure>
<structure>
<property name="name">odaURL</property>
<property name="id">5</property>
</structure>
<structure>
<property name="name">odaUser</property>
<property name="id">5</property>
<expression name="value">if(params["location"]==20)
{
'MISS1'
}else{
'MISS2'
}
</expression>
</structure>
<structure>
<property name="name">odaPassword</property>
<property name="id">5</property>
</structure>
<structure>
<property name="name">odaJndiName</property>
<property name="id">5</property>
</structure>
<structure>
<property name="name">OdaConnProfileName</property>
<property name="id">5</property>
</structure>
<structure>
<property name="name">OdaConnProfileStorePath</property>
<property name="id">5</property>
</structure>
</list-property>
<property name="theme">defaultTheme</property>
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="DataSource" id="5">
<property name="odaDriverClass">oracle.jdbc.driver.OracleDriver</property>
<property name="odaURL">jdbc:oracle:thin:
@ge
:1521:SAA</property>
<property name="odaUser">abc</property>
<encrypted-property name="odaPassword">REVWX01JU1NJU1NJUFBJ</encrypted-property>
</oda-data-source>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="DataSource1" id="6">
<property name="odaDriverClass">oracle.jdbc.driver.OracleDriver</property>
<property name="odaURL">jdbc:oracle:thin:
@10
.226.303.23:1521:SIT</property>
<property name="odaPassword">KS124</property>
<property name="odaUser">rbhihui</property>
</oda-data-source>
</data-sources>
In this library file I am trying to access a param called location which is a scalar parameter coming from .rptdesign file.But here the problem is I am not able to get the location value into .rptlibrary file.So,because of this,it is taking the hard coded values for datasource.So,please tell me how to get a binding parameter into this .rptlibrary file.Plz help me…………..
bhanley
It looks as though you are trying to access your parameters in the wrong place. Parameters are report-level entities and as such you would need to access them at that level in the overall hierarchy.
In reading your description it seems that you have a library and you are trying to access report parameters there. Can you post the design and library so we can have a better look? I am fairly sure this is just a case of making sure the data (in this case a parameter) is being accessed by the correct component at the correct time in the report generation process.
PraveenCh
Thanks for your response bhanley.
The below one is my rptdesign file:
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="
http://www.eclipse.org/birt/2005/design"
; version="3.2.14" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 2.2.0.v20070620 Build <2.2.0.v20070626-1003></property>
<property name="units">in</property>
<property name="comments">Copyright (c) 2007 <<Your Company Name here>></property>
<html-property name="description">Creates a blank report with no predefined content.</html-property>
<list-property name="propertyBindings">
<structure>
<property name="name">odaDriverClass</property>
<property name="id">583</property>
</structure>
<structure>
<property name="name">odaURL</property>
<property name="id">583</property>
</structure>
<structure>
<property name="name">odaUser</property>
<property name="id">583</property>
</structure>
<structure>
<property name="name">odaPassword</property>
<property name="id">583</property>
</structure>
<structure>
<property name="name">odaJndiName</property>
<property name="id">583</property>
</structure>
<structure>
<property name="name">OdaConnProfileName</property>
<property name="id">583</property>
</structure>
<structure>
<property name="name">OdaConnProfileStorePath</property>
<property name="id">583</property>
</structure>
</list-property>
<text-property name="displayName">Blank Report</text-property>
<property name="iconFile">/templates/blank_report.gif</property>
<list-property name="libraries">
<structure>
<property name="fileName">MELibrary.rptlibrary</property>
<property name="namespace">MELibrary</property>
</structure>
</list-property>
<parameters>
<scalar-parameter name="policyId" id="3658">
<property name="valueType">static</property>
<property name="dataType">integer</property>
<property name="controlType">text-box</property>
<property name="defaultValue">22255</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
<scalar-parameter name="endtId" id="3659">
<property name="valueType">static</property>
<property name="dataType">integer</property>
<property name="controlType">text-box</property>
<property name="defaultValue">0</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
<scalar-parameter name="isWebCustomer" id="3754">
<property name="valueType">static</property>
<property name="dataType">boolean</property>
<property name="controlType">check-box</property>
<property name="defaultValue">false</property>
<structure name="format"/>
</scalar-parameter>
<scalar-parameter name="language" id="3837">
<property name="valueType">static</property>
<property name="dataType">string</property>
<property name="controlType">text-box</property>
<property name="defaultValue">E</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
<scalar-parameter name="draft" id="3886">
<property name="valueType">static</property>
<property name="dataType">boolean</property>
<property name="controlType">check-box</property>
<property name="defaultValue">false</property>
<structure name="format"/>
</scalar-parameter>
<scalar-parameter name="location" id="1449">
<property name="valueType">static</property>
<property name="dataType">string</property>
<property name="controlType">text-box</property>
<property name="defaultValue">20</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
</parameters>
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="DataSource" id="3976"
extends="MELibrary.DataSource"/>
</data-sources>
<data-sets>
<oda-data-set extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" name="vehicleDetails" id="3657">
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">YEAROFMAN</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">VEH_DATE_OF_REGN</property>
<property name="dataType">date-time</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">VEH_NCB_YEARS</property>
<property name="dataType">decimal</property>
</structure>
</oda-data-set>
</data-sets>
The below one is my rptlibrary file:
<?xml version="1.0" encoding="UTF-8"?>
<library xmlns="
http://www.eclipse.org/birt/2005/design"
; version="3.2.14" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 2.2.0.v20070620 Build <2.2.0.v20070626-1003></property>
<property name="units">in</property>
<property name="comments">Copyright (c) 2007 <<Your Company Name here>></property>
<list-property name="propertyBindings">
<structure>
<property name="name">odaDriverClass</property>
<property name="id">5</property>
</structure>
<structure>
<property name="name">odaURL</property>
<property name="id">5</property>
</structure>
<structure>
<property name="name">odaUser</property>
<property name="id">5</property>
<expression name="value">if(params["location"]==20)
{
'MISS'
}else{
'ISSISSI'
}
</expression>
</structure>
<structure>
<property name="name">odaPassword</property>
<property name="id">5</property>
</structure>
<structure>
<property name="name">odaJndiName</property>
<property name="id">5</property>
</structure>
<structure>
<property name="name">OdaConnProfileName</property>
<property name="id">5</property>
</structure>
<structure>
<property name="name">OdaConnProfileStorePath</property>
<property name="id">5</property>
</structure>
</list-property>
<property name="theme">defaultTheme</property>
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="DataSource" id="5">
<property name="odaDriverClass">oracle.jdbc.driver.OracleDriver</property>
<property name="odaURL">jdbc:oracle:thin:
@gme
:1521:AM</property>
<property name="odaUser">abc</property>
<encrypted-property name="odaPassword">REVWX01JU1NJU1NJUFBJ</encrypted-property>
</oda-data-source>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="DataSource1" id="6">
<property name="odaDriverClass">oracle.jdbc.driver.OracleDriver</property>
<property name="odaURL">jdbc:oracle:thin:
@10
.226.303.23:1521:SIT</property>
<property name="odaPassword">yuguy</property>
<property name="odaUser">kghi_igi</property>
</oda-data-source>
</data-sources>
<themes>
<theme name="defaultTheme" id="4"/>
</themes>
<page-setup>
<simple-master-page name="NewSimpleMasterPage" id="3"/>
</page-setup>
</library>
But here the problem is property binding is not happening in rptlibrary file.That means it is not possible to get a param from rptdesign file to rptlibrary file.Then how can i change the datasource runtimely in my rptlibrary file?I have totally 40 rptdesign files.In every rptdesign file i am loading same rptlibrary file.So that,in future if add a new datasource in my rptlibrary file,then it should affect in every rptdesign file.plz tel me how to do that..
bhanley
I think you are using the library incorrectly. Can you first explain why you are defining so many data sources? I would think the ability to parameterize almost every facet of the Data Source itself should provide all the flexibility you need in order to make your data source adapt to your needs at run time.
If you have a requirement that cannot be met by the parameter-binding capabilities built into the standard data source, I think you are going to need to develop some scripting to evaluate your parameter and select the correct data source and data set from you rptlibrary at run time.
PraveenCh
In ur rptdesign file write a javascript method called "Initialize"
<method name="initialize"><![CDATA[
var location=params["location"];
reportContext.setPersistentGlobalVariable("loc", location);
]]>
</method>
In the above code your putting location into a globalvariable called loc.After this in your rptlibrary file write a method called "beforeopen"(this method is called before ur datasource opens a connection ).
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="DataSource" id="5">
<method name="beforeOpen"><![CDATA[importPackage(Packages.java.util.logging);
importPackage(Packages.logging);
var loc=reportContext.getPersistentGlobalVariable("loc");
if(loc==20){
this.setExtensionProperty("odaDriverClass", 'oracle.jdbc.driver.OracleDriver');
this.setExtensionProperty("odaURL", 'jdbc:oracle:thin:
@gvme
:1521:RME');
this.setExtensionProperty("odaUser", 'DEVASAS_MISXCAI');
this.setExtensionProperty("odaPassword",'DEVXCA_MICSPI');
}else if(loc==3){
this.setExtensionProperty("odaDriverClass", 'oracle.jdbc.driver.OracleDriver');
this.setExtensionProperty("odaURL", 'jdbc:oracle:thin:
@10
.226.363.263:1521:RIT');
this.setExtensionProperty("odaUser", 'KAIDSDN_MSDDSPPI');
this.setExtensionProperty("odaPassword",'KFSF2');
}
]]>
</method>
</oda-data-source>
</data-sources>
Now based on the location your datasource switches.I think this solves your problem..
Happy VUGAADI.
Bye..