Home
Analytics
How to link rptlibrary with the datasource?
Kuzhali
Hi,
I am new to BIRT.
I want to map the exiting rptlibrary with the new Data Source created by me with different database. But how to do this?. I don't want to delete the existing DataSource & the linked library. All i want is to map the same library for the different datasource too. Help me out.
Find more posts tagged with
Comments
Virgil Dodson
Hi Kuzhali,
I'm not sure I understand completely.
If you are trying to use a data source from a library, You can just drag the data source from the library into your report outline... and then on each Data Set properties, you can associate the query with your library Data Source.
If you are trying to use the same data source with different connections, perhaps for development and production servers, then you can control this in the Data Source property binding tab.
Let me know if you meant something else.
mwilliams
Hi Kuzhali,
Can you explain more what your problem is? I don't think I'm understanding. Do you have a dataSource created in a library and want to have another dataSource as well? Or are you talking about a whole new report with a new dataSource?
Kuzhali
I have a dataSource created in a library and want to have another dataSource as well.. And I wanted to know the possiblity to have two different rpt libraries mapped with two different datasource..
Virgil Dodson
Sure, the same report can use multiple libraries with one Data source each... or one library with multiple data sources in it.
Kuzhali
Hi,
Need your help again on the same topic..
Now, i have one rpt library, which is mapped with one data source.. Now what i want is to have 9 different data sources in the same rpt library. How to do that?..
Do i have to change the property binding settings?..but even if i change the property binding settings, the pointed database url will be the same only right?..
So, do I need to create a new datasource itself?..Help me out..
My ultimate aim is, my application has to point 9 different databases, based on the location. Whenever the user logs into the application using different locations, that particular location database related report should get displayed..
bhanley
<blockquote class='ipsBlockquote' data-author="Kuzhali"><p>
My ultimate aim is, my application has to point 9 different databases, based on the location. Whenever the user logs into the application using different locations, that particular location database related report should get displayed..</p></blockquote>
<br />
Do you just need to shift the connection properties based on user input? I think if that is the case you are over-complicating things by creating 9 different data sources. You can create a single data source and then work with it using property bindings. Each component on the Property Binding for the Data Source can bwe controlled in an expression editor. This gives you the ability to evaluate user input (like parameters) and build out the property at run time.<br />
<br />
Doing this will give your report much more flexibility in deployment so when a 10th DB is added you can support it without much (if any) work at all.<br />
<br />
Take a look at this post form more background: <br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.com/forum/designing-birt-reports/13568-problems-data-source.html#post42493'>http://www.birt-exchange.com/forum/designing-birt-reports/13568-problems-data-source.html#post42493</a>
; <br />
<br />
--Brian
Kuzhali
Hi,
Even if i do the changes in the property binging they aren't getting reflected properly. I am confused.
Let me tell you the steps which I followed..
Step 1 : Double clicked the Datasources
Step 2 : Got the "Edit DataSource" screen
Here i have three options namely 1. BIRT JDBC Data Source 2. connection Profile 3. Property Binding
Step 3 : Click on the Property binding.
There in the JDBC Driver URL , I gave the values as follows:
if (params["country"]==01||params["country"]==02||params["country"]==22)
{
"jdbc: oracle:thin:
@serverNm
: port: DBName1"
}
else if (params["country"]==20)
{
"jdbc: oracle:thin:
@serverNm
: port: DBName2"
}
& In user name & Password also I did the same kind of changes like :
if (params["country"] == 01)
{
'testdb1'
}
else if (params["location"] == 02)
{
'testdb1'
}
else if (params["location"] == 20)
{
'testdb2'
}
But i am not sure why it is working differently sometimes.
If the country value is 02..it should point the DBName1. Instead it is poing the DBName2, if DBName2 is the Data base defined in the 'BIRT JDBC Data Source'..
Can you please let me know that where it is going wrong..
PraveenCh
<blockquote class='ipsBlockquote' data-author="PraveenCh"><p>hi kuzhali,this is the solution for ur problem.<br />
In ur rptdesign file write a javascript method called "Initialize"<br />
<method name="initialize"><![CDATA[<br />
var location=params["location"];<br />
reportContext.setPersistentGlobalVariable("loc", location);<br />
]]><br />
</method><br />
<br />
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 ).<br />
<data-sources><br />
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="DataSource" id="5"><br />
<br />
<method name="beforeOpen"><![CDATA[importPackage(Packages.java.util.logging);<br />
importPackage(Packages.logging);<br />
<br />
var loc=reportContext.getPersistentGlobalVariable("loc");<br />
<br />
if(loc==20){<br />
this.setExtensionProperty("odaDriverClass", 'oracle.jdbc.driver.OracleDriver');<br />
this.setExtensionProperty("odaURL", 'jdbc:oracle:thin:
@gvme
:1521:RME');<br />
this.setExtensionProperty("odaUser", 'DEVASAS_MISXCAI');<br />
this.setExtensionProperty("odaPassword",'DEVXCA_MICSPI');<br />
}else if(loc==3){<br />
this.setExtensionProperty("odaDriverClass", 'oracle.jdbc.driver.OracleDriver');<br />
this.setExtensionProperty("odaURL", 'jdbc:oracle:thin:
@10
.226.363.263:1521:RIT');<br />
this.setExtensionProperty("odaUser", 'KAIDSDN_MSDDSPPI');<br />
this.setExtensionProperty("odaPassword",'KFSF2');<br />
} <br />
]]><br />
</method><br />
<br />
<br />
</oda-data-source><br />
</data-sources><br />
<br />
<br />
Now based on the location your datasource switches.I think this solves your problem..<br />
Happy VUGAADI.<br />
Bye..</p></blockquote>
<br />
with regards<br />
praveen Kumar CH