custom datasource in the jasper report

we are trying to pass a custom data source (postgresql function) to a jasper report from servlet. the code in the servlet is as follows:

    Map<String, Object> hm = new HashMap<String, Object>();
    JRDataSource datasource =  new PostgreSqlDatasource(conectionn, string1, 
    string2, string3);
    hm.put("report_custom_DataSource", datasource );

we have a parameter named report_custom_DataSource in the jrxml report , which is of type jr datasource. but this approach is not passing the required datasource to the report , as a result the report is not rendering on the UI . Please let us know the correct way to pass a custom data source to a jasper report.

barsha_choudhury's picture
Joined: Aug 8 2017 - 3:51am
Last seen: 5 years 7 months ago

2 Answers:

Some reference, http://community.jaspersoft.com/wiki/how-create-and-use-jrdatasource-adapter.   And for the server, there used to be samples here, c:\jasperreports-server\samples\customDataSource\src\example\cds.   

H Mendoza's picture
1717
Joined: Feb 20 2013 - 11:39am
Last seen: 3 years 9 months ago

while this approach works , if we have hard coded values in the data source class, and the report renders fine with these values. the question is how to get values from a postgresql database function/procedure. we need certain parameters to be passed from the report to the function, so that data is generated dynamically. 

barsha_choudhury's picture
Joined: Aug 8 2017 - 3:51am
Last seen: 5 years 7 months ago
Feedback
randomness