JasperFillManager.fillReport and mongo?

戏子无情 提交于 2019-12-11 07:54:04

问题


I'am currently following a tutorial ( http://kristantohans.wordpress.com/2010/03/01/new-to-jasperreport-build-your-first-impressive-application-part-2/ ) and he use a java db connection (conn)

50          try {
51       //Fill the report with parameter, connection and the stream reader    
52              JasperPrint jp = JasperFillManager.fillReport(is, null, conn);

How can i do to connect to mongo here ? Because with mongo i have :

Mongo m = new Mongo( "localhost" , 27017 );
DB db = m.getDB( "test" );

and

JasperPrint jp = JasperFillManager.fillReport(is, null, m);

doesn't work

Thanks !


回答1:


You can't use Jasper Reports with MongoDB as its data provider directly, because MongoDB's driver is not JDBC compatible.

You can fetch your data from MongoDB and wrap it into an JRDataSource, there are some available implementations of JRDataSourche such as JRBeanArrayDataSource and JRBeanCollectionDataSource.

For more information about JRDataSource and implementations visit http://jasperreports.sourceforge.net/api/index.html



来源:https://stackoverflow.com/questions/9327718/jasperfillmanager-fillreport-and-mongo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!