1

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 !

Parvin Gasimzade
  • 25,180
  • 8
  • 56
  • 83
Louis
  • 622
  • 2
  • 10
  • 26
  • This question is better answered here: http://stackoverflow.com/questions/9332373/generatepdf-with-jasperreports-library-and-mongodb – mdahlman Feb 17 '12 at 19:11

1 Answers1

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

Amir Pashazadeh
  • 7,170
  • 3
  • 39
  • 69
  • Thanks ! If someone has some example that would be helpful. – Louis Feb 17 '12 at 12:20
  • @LouisLonjon [This article](http://jasperforge.org/plugins/mwiki/index.php/Bigdatareportingfornosqlandhadoop/MongoDB) is about how to make MongoDB connection – Alex K Feb 17 '12 at 12:23
  • 1
    To be clear for future readers: you CAN use JasperReports with MongoDB as its data provider directly. The link from @AlexK shows how to get started. (But Amir is right about the mongo-java-driver not being a JDBC driver.) – mdahlman Feb 17 '12 at 19:14
  • @mdahlman - How we can download the required jar file? I dont see any jar file here:: http://jasperreports.sourceforge.net/api/index.html –  Jan 18 '17 at 16:10