0

Spec : mongodb-driver-3.3.0.jar,Mongodb Enterprise (Eval),jdk1.7

I have specifically written in 3.0 version of MongoAPI to successfully connect to Db and INSERT data of bulk typos.

Statement: Insert Data to MongoDB Successfully using Mongo-Java API 3.0 using MongoClient , MongoDatabase

Problem : Need to fetch the Data from MongoDB using API MongoClient , MongoDatabase and load the same to a List.

Question : Yah../G..gled / Mong... and could not a single example for this simple solution

Does any body have a Code snippet to share....would be thankfull for the same.

N.S.Karthik
  • 485
  • 13
  • 29
  • Is [this page](http://mongodb.github.io/mongo-java-driver/3.0/driver/getting-started/quick-tour/#get-a-collection) from the documentation helping somehow? – Marco Oct 26 '16 at 06:24
  • What issues do you see while fetching data ? Add your code that you've tried. – s7vr Oct 26 '16 at 09:13
  • MongoClientURI mClientURI = null; String urlnsql = null; try { urlnsql = "mongodb://ABCDSERVER : 27007/?maxPoolSize= 10"); mClientURI = new MongoClientURI(urlnsql ); mClient = new MongoClient(mClientURI); ndbmsConnx = mClient.getDatabase(nsqlx.getDbNameofNsqldB()); } catch (NumberFormatException e) { e.printStackTrace(); }finally{ mClientURI = null; } – N.S.Karthik Oct 26 '16 at 13:05
  • ndbmsConnx.getCollection("myTestCollection"); next what & how to get data/fetch from this collection to POJO ???? – N.S.Karthik Oct 26 '16 at 13:06
  • I recently answered somthing similar. However you have to combine the answers from both posts. Please look at http://stackoverflow.com/questions/40179940/querybuilder-and-basicdbobjectbuilder-usage-in-mongodb-3-3-0-above/40181539#40181539 to get your result iterable with your pojo type and then use http://stackoverflow.com/questions/40246302/finding-distinct-from-collections-in-mongodb/40246563#40246563 to get the iterator from the result from previous step and finally, add and map to the pojo list. – s7vr Oct 27 '16 at 00:20
  • Marco : Yes That the Typos i am using and need ,3.3.0 API to move back all of the Data from Collection into a POJO ( list of Beans) for UI display purpose.... – N.S.Karthik Nov 01 '16 at 05:19

0 Answers0