2012-02-17 12 views
1

I'amは、現在のチュートリアル(http://kristantohans.wordpress.com/2010/03/01/new-to-jasperreport-build-your-first-impressive-application-part-2/) に従い、彼はどのように私はここにモンゴへの接続を行うことができますJavaのDB接続(CONN)JasperFillManager.fillReportとmongo?

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

を使うのか? 私が持っているモンゴであるので:

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

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

おかげで動作しません!

+0

を訪問するが、ここで答え:http://stackoverflow.com/questions/9332373/generatepdf-with-jasperreports-library-and-mongodb – mdahlman

答えて

1

MongoDBのドライバはJDBCと互換性がないため、MongoDBをデータプロバイダとして直接使用することはできません。

MongoDBからデータをフェッチしてJRDataSourceにラップすることができます。JRBeanArrayDataSourceやJRBeanCollectionDataSourceなど、JRDataSourcheの実装がいくつかあります。 JRDataSourceと実装の詳細については

この質問は良いですhttp://jasperreports.sourceforge.net/api/index.html

+0

ありがとう!誰かが参考になるいくつかの例を持っている場合。 – Louis

+0

@LouisLonjon [この記事は](http://jasperforge.org/plugins/mwiki/index.php/Bigdatareportingfornosqlandhadoop/MongoDB)は、MongoDB接続の作成方法です。 –

+0

ありがとうございます。しかし、私はすでにireport @Alexでこれを行っています。 – Louis