当前位置: 代码迷 >> 综合 >> Jasper 动态数据源
  详细解决方案

Jasper 动态数据源

热度:74   发布时间:2023-12-09 15:55:32.0

【问题】

I have more datasources configured in Jasperserver repository. I can get the report,passing parameters, run it from my application and pass the result PDF stream to the client.

I expect I would be able to simply switch the source database. There are predefined parameters “REPORT_DATA_SOURCE” or “REPORT_CONNECTION”. The rest-client interface allows to pass only string values to them. I expected this will work:

runReportAdapter.parameter(“REPORT_DATA_SOURCE”,“/datasources/my_alternative_datasource”);

runReportAdapter.run();

but it doesn’t work. No error is reported but the data are retrieved from original datasource.

【回答】

Jasper 本身不直接支持动态数据源,解决的方法之一是用参数传入 jdbc url/username/password,但会影响安全性(口令在在参数中传递),另一种方法是用 jasper 集成 SPL,由 SPL 根据参数动态决定连接的数据源,并将数据返回 jasper。比如:

A
1
  相关解决方案