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实践中写入以上代码!

猜你喜欢

转载自hrj0130.iteye.com/blog/2213435