package org.bdware.analysis;

public class DataBaseProcess {
    public static void main(String[] args) {
//		long timeJava;
//		try {
//			// start a process before
//			long startJava = System.currentTimeMillis();
//			// authentication: user, dbname, pwd
//			MongoCredential credential = MongoCredential.createCredential("yancloud-dbuser", "yancloud",
//					"yancloud-112".toCharArray());
//			// connect to mongodb server
//			ServerAddress addr = new ServerAddress("39.106.118.0", 27017);
//			List<MongoCredential> credentials = new ArrayList<MongoCredential>();
//			credentials.add(credential);
//			// connect to mongodb database
//			// MongoClient mongoClient = new MongoClient(addr,
//			// Arrays.asList(credential));
//			MongoClient mongoClient = new MongoClient(addr, credentials);
//			MongoDatabase mongoDatabase = mongoClient.getDatabase("yancloud");
//			// list all the documents of collection
//			MongoCollection<Document> collection = mongoDatabase.getCollection("containers");
//			FindIterable<Document> findIterable = collection.find();
//			MongoCursor<Document> mongoCursor = findIterable.iterator();
//			StringBuilder stringBuilder = new StringBuilder();
//			while (mongoCursor.hasNext()) {
//				stringBuilder.append(mongoCursor.next().toJson());
//			}
//			System.out.println(stringBuilder);
//			timeJava = System.currentTimeMillis() - startJava;
//			System.out.println("DataBaseTest of Java: " + timeJava + "\n\t");
//			mongoClient.close();
//			mongoClient = null;
//
//			/*
//			 * findIterable.forEach(new Block<Document>() { public void apply(Document _doc)
//			 * { System.out.println(_doc.toJson()); } });
//			 */
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
    }
}
