Birt data source parameters from a property file

前端 未结 2 389
野趣味
野趣味 2020-12-17 00:52

I have multiple BIRT reports that obtains the data from the same jdbc data source.

Is it possible to obtain the conection parameters (Driver URL, User Name, and Pass

2条回答
  •  囚心锁ツ
    2020-12-17 01:42

    An alternative to the good @Mystik's "Property binding" solution is externalizing to a connection profile.

    • Create a data source (say "DS"), setting up a correct configuration of the parameters to connect to a DB.
    • Right click on "DS" > Externalize to Connection Profile... > check both options, set a name for the Connection Profile, Ok > set the path and filename were to save the Connection Profile Store (say "reportName.cps"), uncheck Encrypt... (in this way we can modify information in the XML file by hand).

    Now we have "reportName.cps", an XML file that we can modify according to the environment where we place our report (development, production,...). The problem is that "DS" has loaded statically those info from "reportName.cps". It loads them dinamically if it can find "reportName.cps" in the absolute path we specified. So changing environment the file path will be different and the report won't find our file. To tell the report the correct location of the file and load it dynamically let's write a script:

    • Setup a beforeOpen script to use the connection profile that is deployed in the resource folder which can be different for every environment:

      var myresourcefolder = reportContext.getDesignHandle().getResourceFolder();
      this.setExtensionProperty("OdaConnProfileStorePath", myresourcefolder + "/reportName.cps");
      

提交回复
热议问题