java - is this considered a bad singleton design for mongoDB? -


public class dataservice {   private static dataservice dataservice;   private static mongoclient mongoclient;    private static mongodatabase db;    static {       try {           mongoclient = new mongoclient( "localhost" , 27017 );           db = mongoclient.getdatabase("mydb");       } catch (exception e) {}   }    private dataservice() {}    public static dataservice getinstance() {       if (dataservice == null) {           dataservice = new dataservice();       }       return dataservice;   }    public mongodatabase getdb() {       return db;   } } 

is bad design access mongodb? , singleton? suggests me solution if bad... sorry english. thank you


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -