简体   繁体   中英

How to pass multiple connection to birt Report?

I can pass database connection to report via java code. Following is how I implemented:

DataSource datasourceOracle= (DataSource)initialContext.lookup("java:jboss/jdbc/BirtConn");
task.getAppContext().put("OdaJDBCDriverPassInConnection", datasourceOracle.getConnection());

My problem is the report is using multiple datasource. So I need to pass two multiple connection to report. How can I?

If you know the details of your connections inside your Java code, you could pass these details instead of just the JNDI names, like this:

task.getAppContext().put("conn1.username", "scott");
task.getAppContext().put("conn1.password", "tiger");
task.getAppContext().put("conn1.url", "oracle:jdbc:thin:@//oracledb:1521/orcl");

task.getAppContext().put("conn2.username", "hr");
task.getAppContext().put("conn2.password", "x");
task.getAppContext().put("conn2.url", "oracle:jdbc:thin:@//other-db:1521/xyz");

Inside the report, you can then use the dataset's property binding dialog to set the values from the context, eg for your first data source:

Database URL: reportContext.getAppContext().get("conn1.name");
User Name:    reportContext.getAppContext().get("conn1.username");
Password:     reportContext.getAppContext().get("conn1.password");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM