Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package br.edu.utfpr.webapp.dao; import com.mongodb.MongoClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MongoUtil { private final static Logger logger = LoggerFactory.getLogger(MongoUtil.class); private static final int port = 27017; private static final String host = "localhost"; private static MongoClient mongo = null; public static MongoClient getMongo() { if (mongo == null) { mongo = new MongoClient(host, port); logger.debug("New Mongo created with [" + host + "] and [" + port + "]"); } return mongo; } }