Birt Report: Read spring configuration file data source information

Source: Internet
Author: User

Birt is integrated in the spring environment. It usually uses the same database configuration as the spring application. To keep the datasource of Birt identical with that of the Web application, make the following settings.

Birt datasources-script-beforeopen

Importpackage (packages.org. springframework. Context. Support); // reference the spring class

Importpackage (packages.org. Apache. commons. DBCP); // apply the datasource class

VaR CTX = new classpathxmlapplicationcontext ("applicationcontext. xml"); // read the spring configuration file

VaR datasource = CTX. getbean ("datasourcename"); // read datasource

Extensionproperties. odaurl = new string (datasource. geturl (); // read the URL and assign a value

Extensionproperties. odauser = new string (datasource. GetUserName (); // read username and assign values

Extensionproperties. odapassword = new string (datasource. GetPassword (); // read the password and assign a value

Report design first comment out these statements

Run these scripts in the running environment.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.