List of usage examples for com.mongodb Mongo Mongo
Mongo(final MongoClientURI mongoURI)
From source file:com.kurento.kmf.repository.internal.repoimpl.mongo.MongoConfiguration.java
License:Open Source License
@Override public Mongo mongo() throws UnknownHostException { return new Mongo(new MongoURI(config.getMongoURLConnection())); }
From source file:com.logger.mongo.MongoDBManager.java
public static MongoDBManager getInstance(String uri, String db) { if (mongoDBManager == null) { synchronized (objLock) { if (mongoDBManager == null) { try { mongoDBManager = new MongoDBManager(); mongoDBManager.mongo = new Mongo(uri); mongoDBManager.db = mongoDBManager.mongo.getDB(db); } catch (UnknownHostException ex) { Logger.getLogger(MongoDBManager.class.getName()).log(Level.SEVERE, null, ex); }//from w w w .j ava 2s . c o m } } } return mongoDBManager; }
From source file:com.lowereast.guiceymongo.guice.spi.DBProviderModule.java
License:Apache License
private Mongo getConnection(String configuration, String databaseKey) throws MongoException, UnknownHostException { String connectionKey = getInstance(_injector, Key.get(String.class, AnnotationUtil.configuredDatabaseConnection(configuration, databaseKey))); if (connectionKey != null) { String hostname = getInstance(_injector, Key.get(String.class, AnnotationUtil.configuredConnectionHostname(connectionKey))); Integer port = getInstance(_injector, Key.get(int.class, AnnotationUtil.configuredConnectionPort(connectionKey))); if (hostname == null) hostname = "localhost"; if (port == null) return new Mongo(hostname); return new Mongo(hostname, port.intValue()); }/* w w w . ja va 2s . c o m*/ return new Mongo(); }
From source file:com.opencanarias.mset.internal.benchmark.repository.cdo.mongodb.JVMMongodbCDOModelRepository.java
License:Open Source License
@Override public boolean isAvailable() { try {/*from www .j ava 2 s .c o m*/ Mongo mongo = new Mongo(MONGO_URI); mongo.getConnector().getDBPortPool(mongo.getAddress()).get().ensureOpen(); } catch (Exception e) { fireRepositoryEvent(EventLevel.ERROR, "MongoDB is not available", e); logger.error("MongoDB is not available", e); return false; } return true; }
From source file:com.opencanarias.mset.internal.benchmark.repository.cdo.mongodb.JVMMongodbCDOModelRepository.java
License:Open Source License
@Override protected void doClean() { try {/* w w w .ja v a 2s .co m*/ Mongo mongo = new Mongo(MONGO_URI); DB db = mongo.getDB(getRepositoryName()); db.dropDatabase(); } catch (UnknownHostException e) { fireRepositoryEvent(EventLevel.ERROR, "Error while cleaning MongoDB", e); logger.error("Error while cleaning MongoDB", e); } }
From source file:com.porvak.bracket.config.EmbeddedDataConfig.java
License:Apache License
@Bean public Mongo mongo() throws UnknownHostException { return new Mongo("127.0.0.1"); }
From source file:com.rmzone.config.SpringMongoConfig.java
License:Open Source License
@Override public @Bean Mongo mongo() throws Exception { return new Mongo("localhost"); // put your MongoDB server address. }
From source file:com.springsource.html5expense.config.LocalDataSourceConfig.java
License:Apache License
@Bean @Override//from w w w. j av a2 s . c om public MongoTemplate mongoTemplate() throws Exception { return new MongoTemplate(new Mongo("127.0.0.1"), "expensesfs"); }
From source file:com.test.mavenproject1.Main.java
public static void main(String[] args) throws Exception { //Load our image byte[] imageBytes = LoadImage("/home/fabrice/Pictures/priv/DSCN3338.JPG"); //Connect to database Mongo mongo = new Mongo("127.0.0.1"); String dbName = "GridFSTestJava"; DB db = mongo.getDB(dbName);/* w w w. ja v a2s.c om*/ //Create GridFS object GridFS fs = new GridFS(db); //Save image into database GridFSInputFile in = fs.createFile(imageBytes); in.save(); //Find saved image GridFSDBFile out = fs.findOne(new BasicDBObject("_id", in.getId())); //Save loaded image from database into new image file FileOutputStream outputImage = new FileOutputStream("/home/fabrice/Pictures/DSCN3338Copy.JPG"); out.writeTo(outputImage); outputImage.close(); }
From source file:com.uquetignyadminapp.connection.ConnectionMongoDB.java
public ConnectionMongoDB() throws UnknownHostException { Mongo mongoClient = new Mongo("localhost"); db = mongoClient.getDB("test"); //boolean auth = db.authenticate(myUserName, myPassword); }