Home
Analytics
Using external config files to load jdbc info
DreamCoder
Hello,
I'm looking to create an xml config file kind of like this:
<config>
<instances>
<instance instance_id="0" jdbc_url="jdbc:mysql://192.168.200.226:3306/crm_dev" username="root" password="pw"/>
<instance instance_id="1" jdbc_url="jdbc:mysql://192.168.200.226:3306/crm_main" username="root" password="mainpw"/>
</instances>
</config>
I would like to be able to dynamically configure my Data Source using this config file. So that I could pass a parameter with the instance_id into the report, the report would look at this file, and create the datasource using the jdbc string associated with that instance_id.
Any idea how I could get this to work?
Much appreciated!
Amanda
Find more posts tagged with
Comments
egau
Hi DreamCoder,<br />
<br />
To see how to write an xml file understable by BIRT, you can try to double click on a data source you've already created, then you go in connection Profile,<br />
then you, and here you enter the location of a file. ( uncheck encrypt if you want to be able to read
) and then you can see how a xml file looks like.<br />
<br />
Or you can just look at this xml : <br />
<br />
<?xml version="1.0" encoding="UTF-8" standalone="no"?><br />
<DataTools.ServerProfiles version="1.0"><br />
<profile autoconnect="No" desc="" id="815e0530-6a64-11de-a0b0-8d3a72e4e1f9" name="New BIRT JDBC Data Source" providerID="org.eclipse.birt.report.data.oda.jdbc"><br />
<br />
<baseproperties><br />
<property name="odaJndiName" value=""/><br />
<property name="odaDriverClass" value="org.eclipse.birt.report.data.oda.sampledb.Driver"/><br />
<property name="odaURL" value="jdbc:classicmodels:sampledb"/> // or 192.168 . . .etc <property name="odaPassword" value=""/><br />
<property name="odaUser" value="root"/><br />
</baseproperties><br />
</profile><br />
</DataTools.ServerProfiles><br />
<br />
<br />
<br />
I don't really know how the "id" variable works, but if you have 2 server, you just have to have 2 different id , i typed "sdfsdf" and it works . . . maybe some people can explain that better than me!<br />
<br />
<br />
After you made your xml file, you just have to create a new data source, but now , you chose "create from a connection profile in profile store" and you take you xml fuile in the browse area. <br />
<br />
You can also use relative path. <br />
<br />
I hope I was clear and I didn't say wrong things!<br />
<br />
egau<br />
<br />
PS : Are you for a IRC BIRT channel during the day, so people can help each other at the speed of light
? If yes , post a message here, I try to motivate as much people as possible to be more efficient during the day ! <br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/forum/designing-birt-reports/15780-irc-birt-channel.html'>http://www.birt-exchange.org/forum/designing-birt-reports/15780-irc-birt-channel.html</a>
;
DreamCoder
Thank you for your reply. Okay so I'm rethinking this a little. I have created my profileConnection:<br />
<br />
<strong class='bbc'>Profile0</strong><br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<DataTools.ServerProfiles version="1.0">
<profile autoconnect="No" desc="Development database for the reporting platform" id="a1745f31-508e-11de-9f98-f200fb859ded" name="Profile0" providerID="org.eclipse.birt.report.data.oda.jdbc">
<baseproperties>
<property name="odaJndiName" value=""/>
<property name="odaDriverClass" value="com.mysql.jdbc.Driver"/>
<property name="odaURL" value="jdbc:mysql://192.168.200.226:3306/crm_dev"/>
<property name="odaPassword" value="sp!phy"/>
<property name="odaUser" value="root"/>
</baseproperties>
<org.eclipse.datatools.connectivity.versionInfo>
<property name="technology.version.org.eclipse.birt.report.data.oda.jdbc" value="3.0.6"/>
<property name="server.version" value="5.0.0"/>
<property name="technology.name.org.eclipse.birt.report.data.oda.jdbc" value="DTP Open Data Access"/>
<property name="server.name" value="MySQL"/>
</org.eclipse.datatools.connectivity.versionInfo>
</profile>
</DataTools.ServerProfiles>
</pre>
<br />
<strong class='bbc'>Profile1</strong><br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<DataTools.ServerProfiles version="1.0">
<profile autoconnect="No" desc="Development database for the reporting platform" id="a1745f31-508e-11de-9f98-f200fb859ded" name="Profile1" providerID="org.eclipse.birt.report.data.oda.jdbc">
<baseproperties>
<property name="odaJndiName" value=""/>
<property name="odaDriverClass" value="com.mysql.jdbc.Driver"/>
<property name="odaURL" value="jdbc:mysql://192.168.200.226:3306/MySQL_CRM_1_DSN"/>
<property name="odaPassword" value="sp!phy"/>
<property name="odaUser" value="root"/>
</baseproperties>
<org.eclipse.datatools.connectivity.versionInfo>
<property name="technology.version.org.eclipse.birt.report.data.oda.jdbc" value="3.0.6"/>
<property name="server.version" value="5.0.0"/>
<property name="technology.name.org.eclipse.birt.report.data.oda.jdbc" value="DTP Open Data Access"/>
<property name="server.name" value="MySQL"/>
</org.eclipse.datatools.connectivity.versionInfo>
</profile>
</DataTools.ServerProfiles>
</pre>
<br />
Now I would like to dynamically choose a profile depending on what is passed in as a parameter. So, I have a parameter named RP_instance - if "0" is passed into that parameter, then I want to use Profile0, if "1" is passed into that parameter, then I want to use Profile1. <br />
<br />
I thought I could just do this in property binding, but I just can't seem to get it to work. It's like it ignores it altogether. Maybe I am doing something wrong? I have put each of those profiles in my SharedResources directory. Then to use the profile I put the following in the Property Binding tab of the DataSource:<br />
<br />
Connection Profile Store URL: "../SharedResources/Profile" + params["RP_instance"].value + ".xml";<br />
<br />
Doesn't work tho. Any ideas? <br />
<br />
Thanks,<br />
Amanda
egau
Hm, I don't know how to do that, maybe in java . . .? I can't help for that, not enough experience :-). <br />
<br />
mwilliams will maybe be able to answer you, but if you succeed, pls explain!<br />
<br />
or join irc://irc.freenode.net/birt maybe we can try to find a solution, it can be usefull also for me !<br />
<br />
<br />
edit: I forget that I watched it actually. You can go in your data source editor ( by double clicking ) and then you go in "Property binding" then you can code javascript for each property ( url, driver , pass etc...) I think you can do it like that.<br />
<br />
edit1: here is the sample related to what i said : <a class='bbc_url' href='
http://wiki.eclipse.org/Change_Database_URL_at_runtime_based_on_Parameter_(BIRT'>Change
Database URL at runtime based on Parameter (BIRT - Eclipsepedia</a>)<br />
<br />
<br />
---- <br />
egau