java Pentaho - 报告工具 - .prpt 文件(报告模板文件)是否也包含数据源信息?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2872079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Pentaho - Reporting Tool - Does the .prpt file (report template file) contains datasource information too?
提问by Yatendra Goel
I am new Pentaho Reporting Tool. I have the following question:
我是新的 Pentaho 报告工具。我有以下问题:
When I created a report using Pentaho Report Designer, it output a report file having .prpt extension. After that I found an example on internet where the following code were used to display the report in html format:|
当我使用 Pentaho Report Designer 创建一个报告时,它输出一个扩展名为 .prpt 的报告文件。之后我在互联网上找到了一个示例,其中使用以下代码以html格式显示报告:|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ResourceManager manager = new ResourceManager();
manager.registerDefaults();
String reportPath = "file:" +
this.getServletContext().getRealPath("sampleReport.prpt");
try {
Resource res = manager.createDirectly(new URL(reportPath), MasterReport.class);
MasterReport report = (MasterReport) res.getResource();
HtmlReportUtil.createStreamHTML(report, response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
And the report got printed successfully. So as we haven't specified any datasource information here, I think that the .prpt file contains that information in it.
并且报告打印成功。因此,由于我们没有在此处指定任何数据源信息,我认为 .prpt 文件中包含该信息。
If that's true than Isn't Jasper is better Reporting tool than Pentaho because when we display Jasper reports, we have to provide datasource details also so in that way our report is flexible and is not bound to any particular database.
如果这是真的,那么 Jasper 不是比 Pentaho 更好的报告工具,因为当我们显示 Jasper 报告时,我们也必须提供数据源详细信息,这样我们的报告就很灵活,不受任何特定数据库的约束。
回答by Codek
Nope. The data source canbe stored in the prpt, but it can be passed to the report too. And the usual way is to simply use JNDI so that you can deploy the same report, to multiple test/dev/production environments.
不。数据源可以存储在 prpt 中,但也可以传递给报表。通常的方法是简单地使用 JNDI,以便您可以将相同的报告部署到多个测试/开发/生产环境。
You'll probably get better quicker answers from the forum. forums.pentaho.org
您可能会从论坛获得更好更快的答案。论坛.pentaho.org
回答by Thomas Morgner
The PRPT file usually contains all information that is needed to run the report. You canprovide your own datasources by modifying the MasterReport object that you get back from the ResourceManager.
PRPT 文件通常包含运行报告所需的所有信息。您可以通过修改从 ResourceManager 返回的 MasterReport 对象来提供您自己的数据源。
However, I yet have to see valid use cases where that kind of operation actually makes sense. To provide connection information for SQL datasources at runtime you usually use the JNDI subsystem of your web-application or J2EE server.
但是,我还没有看到这种操作实际上有意义的有效用例。要在运行时为 SQL 数据源提供连接信息,您通常使用 Web 应用程序或 J2EE 服务器的 JNDI 子系统。
99.99% of all reports that run on the Pentaho BI-Server do NOThave a need to manually replace datasources to run. And the remaining 0.01% are legacy reports from ancient reporting engine versions.
所有报告的99.99%,该Pentaho的BI-服务器上运行根本不是有需要手动更换数据源来运行。剩下的 0.01% 是来自古老报告引擎版本的遗留报告。

