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
Post a Comment