Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure dynamic data sources for BIRT

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor will show you how to configure dynamic data sources in BIRT. The knowledge points in this article are introduced in great detail. Friends who feel helpful can browse the content of the article with the editor, hoping to help more friends who want to solve this problem to find the answer to the problem. Follow the editor to learn more about "how to configure dynamic data sources in BIRT".

BIRT itself does not directly support dynamic data sources, and a common solution is to add code similar to the following in the beforeopen event of the data source:

...

ImportPackage (Packages.java.io)

ImportPackage (Packages.java.util)

Fin = new java.io.FileInputStream (new String ("d:/config.txt"))

Props = new java.util.Properties ()

Props.load (fin)

ExtensionProperties.odaDriverClass = new String (props.getProperty ("driver"))

ExtensionProperties.odaURL = new String (props.getProperty ("url"))

ExtensionProperties.odaUser = new String (props.getProperty ("username"))

ExtensionProperties.odaPassword = new String (props.getProperty ("password"))

Fin.close ()

...

This is solved by hard coding (either a large number of report files need to be modified, or each report needs to inherit a common library file), the process is still more complex, when there are a large number of reports and a large number of developers, there are a lot of things to pay attention to, and it's not perfect.

If there is an aggregator, this problem is much simpler, and its unique macro replacement mechanism greatly improves the degree of code reuse, and different results are obtained according to different parameter values.

For example, to deal with such a scenario: the data sources myDB and oraDB point to different databases, and there is a table ORDER with the same structure in the two databases. The report needs to dynamically connect the data source according to the parameters, query and display orders with an amount greater than 1000 in ORDER. The schematic diagram is as follows:

The aggregator SPL is done with only one line:

A

one

= ${pSource} .query ("select * from ORDER where Amount > 1000")

Where pSource is the report parameter, representing the data source name, ${… } means to parse a string into an expression. In fact, there are many cases where BIRT is not convenient to solve dynamic computing problems, but it is very simple with the help of the aggregator SPL. The aggregator provides a JDBC driver, which can be easily integrated with report tools such as BIRT. BIRT calls the SPL script to use and get it.

Thank you for your reading, the above is the whole content of "how to configure dynamic data sources in BIRT", learn friends to hurry up to operate it. I believe that the editor will certainly bring you better quality articles. Thank you for your support to the website!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report