JasperFillManager.fillReport和mongo? [英] JasperFillManager.fillReport and mongo?
问题描述
我目前正在关注一个教程( http://kristantohans.wordpress.com/2010/03/01/new-to-jasperreport-build-your-first-impressive-application-part-2/ )
他使用java数据库连接(conn)
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);
如何在这里连接到mongo?
因为有mongo我有:
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" );
和
JasperPrint jp = JasperFillManager.fillReport(is, null, m);
不起作用
谢谢!
推荐答案
您不能直接将Jasper Reports与MongoDB一起用作数据提供者,因为MongoDB的驱动程序不兼容JDBC。
You can't use Jasper Reports with MongoDB as its data provider directly, because MongoDB's driver is not JDBC compatible.
您可以从MongoDB获取数据并将其包装到JRDataSource中,JRDataSourche有一些可用的实现,例如JRBeanArrayDataSource和JRBeanCollectionDataSource。
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.
有关JRDataSource和实现的更多信息,请访问 http://jasperreports.sourceforge.net/ api / index.html
For more information about JRDataSource and implementations visit http://jasperreports.sourceforge.net/api/index.html
这篇关于JasperFillManager.fillReport和mongo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!