Configuring data source connections in iHub : Using a connection configuration file : Setting up the connection configuration file
 
Setting up the connection configuration file
In a BIRT report design, the configuration key that specifies a data source is the concatenation of the ODA plug-in’s data source extension ID and the data source design name separated by an underscore (_) character.
The connection property names are the connection properties defined for your data source. To find the correct names for the connection properties, check the data source definition in the XML source of the BIRT report design file. You can view the report’s XML source by selecting the XML Source tab in the report editor.
The code example in Listing 24‑3 shows the XML definition of a MySQL Enterprise database in a report design. Using this data source, the report developer can test the report in development. This XML data source definition specifies the connection properties, odaDriverClass, odaURL, odaUser, and odaPassword, for the data source, ClassicModels.
Listing 24‑3 The XML definition of a MySQL Enterprise database
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="Customers" id="4">
<property name="odaDriverClass">
com.mysql.jdbc.Driver
</property>
<property name="odaURL">
jdbc:mysql://localhost/ClassicModels
</property>
<property name="odaUser">root</property>
<property name="odaPassword">pwd</property>
</oda-data-source>
</data-sources>
At run time, the report uploaded to iHub connects to a production database that resides on a different database server. The connection properties specify a machine IP address, 192.168.218.226, and a different username and password. To externalize the database connection information, create the configuration property file, DBConfig.xml, with the settings shown in Listing 24‑4.
Listing 24‑4 A configuration property file that connects to a production database
<Config>
<Runtime>
<ConnectOptions Type="org.eclipse.birt.report.data.oda.jdbc_Customers">
<Property PropName="odaDriverClass">
com.mysql.jdbc.Driver
</Property>
<Property PropName="odaURL">
jdbc:mysql://192.168.218.226:3306/ClassicModels
</Property>
<Property PropName="odaUser">operator</Property>
<Property PropName="odaPassword">pwd</Property>
</ConnectOptions>
</Runtime>
</Config>