Package com.mongodb

Examples of com.mongodb.MongoClientURI


        int cacheSize = PropertiesUtil.toInteger(config.get(PROP_CACHE), DEFAULT_CACHE);
        boolean useMK = PropertiesUtil.toBoolean(config.get(PROP_USE_MK), false);

        MongoClientOptions.Builder builder = MongoConnection.getDefaultBuilder();
        MongoClientURI mongoURI = new MongoClientURI(uri,builder);

        if(logger.isInfoEnabled()){
            //Take care around not logging the uri directly as it
            //might contain passwords
            String type = useMK ? "MicroKernel" : "NodeStore" ;
            logger.info("Starting MongoDB {} with host={}, db={}",
                    new Object[] {type,mongoURI.getHosts(), db});
            logger.info("Mongo Connection details {}",MongoConnection.toString(mongoURI.getOptions()));
        }

        MongoClient client = new MongoClient(mongoURI);
        DB mongoDB = client.getDB(db);
View Full Code Here


        properties = new Properties();
        InputStream is = MongoDbConversionsTest.class.getResourceAsStream("/mongodb.test.properties");
        properties.load(is);
        // ping Mongo and populate db and collection
        try {
            mongo = new MongoClient(new MongoClientURI(properties.getProperty("mongodb.connectionURI")));
            mongo.getDatabaseNames();
            dbName = properties.getProperty("mongodb.testDb");
            db = mongo.getDB(dbName);
        } catch (Exception e) {
            Assume.assumeNoException(e);
View Full Code Here

            new BlogController(args[0]);
        }
    }

    public BlogController(String mongoURIString) throws IOException {
        final MongoClient mongoClient = new MongoClient(new MongoClientURI(mongoURIString));
        final DB blogDatabase = mongoClient.getDB("blog");

        blogPostDAO = new BlogPostDAO(blogDatabase);
        userDAO = new UserDAO(blogDatabase);
        sessionDAO = new SessionDAO(blogDatabase);
View Full Code Here

            new BlogController(args[0]);
        }
    }

    public BlogController(String mongoURIString) throws IOException {
        final MongoClient mongoClient = new MongoClient(new MongoClientURI(mongoURIString));
        final DB blogDatabase = mongoClient.getDB("blog");

        blogPostDAO = new BlogPostDAO(blogDatabase);
        userDAO = new UserDAO(blogDatabase);
        sessionDAO = new SessionDAO(blogDatabase);
View Full Code Here

    if (mongoURIString == "") {
      uri = "mongodb://localhost";
    } else {
      uri = mongoURIString;
    }
    final MongoClient mongoClient = new MongoClient(new MongoClientURI(uri));
    chatDatabase = mongoClient.getDB("rilachatjava");

  }
View Full Code Here

 
 
  public MessagesHistoryMongoTest(){
    MongoClient mongoClient;
    try {
      mongoClient = new MongoClient(new MongoClientURI(
          "mongodb://localhost"));
      chatDatabase = mongoClient.getDB("rilachatjavaTest");
     
    } catch (UnknownHostException e) {
      // TODO Auto-generated catch block
View Full Code Here

  public MessagesHistoryMongo() {
    String uri = "mongodb://localhost";
    MongoClient mongoClient;
    try {
      mongoClient = new MongoClient(new MongoClientURI(uri));
      chatDatabase = mongoClient.getDB("chatTest");
    } catch (UnknownHostException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    if (mongoURIString == "") {
      uri = "mongodb://localhost";
    } else {
      uri = mongoURIString;
    }
    final MongoClient mongoClient = new MongoClient(new MongoClientURI(uri));
    chatDatabase = mongoClient.getDB("chat");

  }
View Full Code Here

            }
        } else {
            if (dbUrl != null) {
                dbUrl = dbUrl.trim();
                try {
                    final MongoClientURI uri = new MongoClientURI(dbUrl);
                    mongoClient = (MongoClient) Mongo.Holder.singleton().connect(uri);
                    db = mongoClient.getDB(uri.getDatabase());
                } catch (final Exception e) {
                    throw BatchMessages.MESSAGES.invalidConfigProperty(e, JdbcRepository.DB_URL_KEY, dbUrl);
                }
            }
        }
View Full Code Here

    private static Datastore dataStore;

    public static Mongo getMongo() {
        if (mongo == null) {
            try {
                MongoClientURI clientURI = new MongoClientURI("mongodb://developer:12345678@ds033499.mongolab.com:33499/academic");
                mongo = new MongoClient(clientURI);
            } catch (UnknownHostException e) {
                e.printStackTrace();
            }
        }
View Full Code Here

TOP

Related Classes of com.mongodb.MongoClientURI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.