`
liulanghan110
  • 浏览: 1063945 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

birt读取现有系统的数据库配置作为数据源

    博客分类:
  • JAVA
 
阅读更多

Birt的数据源可以用多种形式,当我们把BIRT嵌入到现有系统时,一般想读取现有系统的数据库配置。那么怎样读取呢,配置如下:

 

建议脚本数据源。然后在beforeOpen中加入如下代码:

importPackage(Packages.org.springframework.context.support);//引用Spring类

importPackage(Packages.org.apache.commons.dbcp);//应用Datasource类

var ctx = new ClassPathXmlApplicationContext("birt-context.xml");//读取Spring配置文件

var dataSource = ctx.getBean("dataSource");//读取DataSource

extensionProperties.odaURL = new String(dataSource.getUrl());//读取Url并赋值

extensionProperties.odaUser = new String(dataSource.getUsername());//读取Username并赋值

extensionProperties.odaPassword = new String(dataSource.getPassword());//读取Password并赋值

 其中birt-context.xml里面有现有系统的数据库配置

0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics