Data Source Connection Details Passing from Jasper Server to SubReport Dynamically
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
Here is how we get it working using a MYSQL connection for a subreport which removes the need to hard code the connection to the sub report’s data source on Jaspeserver
Prerequisites:: Ireport 5.6 ,Jasper server 5.6
DataBase : Foodmart,SugarCRM
Step 1 : Create a Main Report with Two Subreports , one subreport pointing to Main Data Source i.e., SugarCRM and for other SubReport foodmart details we need to pass Dynamically
Step 2 : Pass the main data source to the report unit as usual, and create the other data source on jasper server you want to use in the sub report
Step 3 : In the main report, create a parameter $P{DATA_SOURCE_PATH} where
Parameter Class : com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.JdbcReportDataSource
Default Expression :
com.jaspersoft.jasperserver.api.engine.jasperreports.util.RepositoryUtil.getThreadRepositoryContext().getRepository().getResource(null,”/datasources/FOODMART”)
In Default Expression we need to pass the DataSource Path which we have created for SubReport
Step 4 : Now we can call functions on this parameter and pass in the connection to your subreport as follows
Create a parameter that you will pass to the subreport named SUBREPORT_CONNECTION
Default Expression :
java.sql.DriverManager.getConnection($P{DATA_SOURCE_PATH}.getConnectionUrl(),$P{DATA_SOURCE_PATH}.getUsername(),$P{DATA_SOURCE_PATH}.getPassword())
Step 5 : Pass SUBREPORT_CONNECTION parameter to SubReport
Step 6 : Deployed in Server and Verify once
Output in Jasper Sever:
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
Best Open Source Business Intelligence Software Helical Insight is Here
A Business Intelligence Framework
Thanks,
Satya Gopi Parisa,
BI Developer.