I have been getting some strange errors with Mongodb, and in Mongodb, you are supposed to mainatin the Mongo singleton. I just wanted to make sure that this is infact valid.
public class DBManager {
public static Mongo mongoSingleton = null;
public static synchronized void getMongo(){
if(mongoSingleton == null){
mongoSingleton = new Mongo();
}
return mongoSingleton;
}
}
Thanks!
You have to set your public member mongoSingleton as private and to hide the default constructor
so
the class Mongo implementation
usage