birt一点一滴系列之读取数据库配置文件
importPackage( Packages.java.io,Packages.java.util );
dbConfigPath = reportContext.getClass().getResource("/dbConifg.properties").getPath();
fin = new java.io.FileInputStream(dbConfigPath);
props = new java.util.Properties();
props.load(fin);
odaURL = new String(props.getProperty("url"));
odaUser = new String(props.getProperty("username"));
odaPassword = new String(props.getProperty("password"));
if(odaURL != null)
{
this.setExtensionProperty("odaURL",odaURL);
}
if(odaUser != null)
{
this.setExtensionProperty("odaUser",odaUser);
}
if(odaPassword != null)
{
this.setExtensionProperty("odaPassword",odaPassword);
}
fin.close();
点击数据源节点,选择脚本。在beforeOpen实践中写入以上代码!