MongoDB, Java: accessing cursor opens connection that cannot be closed -


i have problem close connection created after accessing mongodb cursor.

i gathering information connections console of running mongod instance. not using mongodb replication nor sharding yet.

for example sample code causing opened connection (assume 'myquery' query, coll mapped using setinternalclass class myobject):

  dbcursor find = coll.find(myquery);   list<myobject> myobjects = new arraylist<myobject>();   while(find.hasnext()) { // line opens connection         myobject next = (myobject) find.next();         myobjects.add(next);   }   find.close(); // line not close connection 

you calling close on find object, dbcursor. mentioned in api documentation close cursor, not underlying connection. close connections should call close on mongo/mongoclient object, either inherits or has close function as per api close connections mongodb server instance.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -