我们已经在eclips设计中创建了Birt报表,并且我们使用Birt jdbc数据源连接到derby数据库。现在,我们将在mysql数据库中使用相同的报告。每次我们都需要在每个报表中编辑这个数据源。我们希望在java/maven中有一个属性,在这里我们可以更改驱动程序类和数据库URL。
我们已经遵循了这个链接How to set a datasource for a BIRT report programmatically?上的说明。
但在这里,他将在运行时使用动态数据库url。但不希望在运行时这样做,它必须永久更改,直到我们通过maven再次更改它为止。
发布于 2014-03-19 07:26:19
我们找到了解决办法。在birt报告中,我们使用jdbc数据源(属性绑定):
if ( params["database"] == "derby" ){
"jdbc:derby://localhost:1527/databaseName;user=user;password=password";
}else if ( params["database"] == "mysql" ) {
"jdbc:mysql://localhost:3306/databaseName?user=root";
}因此,我们创建了一个参数,可以在运行时选择derby或mysql。
我们还使用report web查看器,因此我们在网页中显示该报告:
<birt:viewer id="WebApp" reportDesign="report.rptdesign" format="html" ></birt:viewer>现在,我们在这个查看器中使用这样的参数:
<birt:viewer id="WebApp" reportDesign="report.rptdesign" format="html" >
<birt:param name="database" value='mysql'></birt:param>
</birt:viewer>参数值将通过使用maven配置文件自动更改。
https://stackoverflow.com/questions/22476573
复制相似问题