Package com.mongodb

Examples of com.mongodb.MongoClient


                throw new ManifoldCFException("GridFS: Metadata URL field cannot be empty.");
            }

            if (StringUtils.isEmpty(host) && StringUtils.isEmpty(port)) {
                try {
                    session = new MongoClient().getDB(db);
                } catch (UnknownHostException ex) {
                    throw new ManifoldCFException("GridFS: Default host is not found. Does mongod process run?" + ex.getMessage(), ex);
                }
            } else if (!StringUtils.isEmpty(host) && StringUtils.isEmpty(port)) {
                try {
                    session = new MongoClient(host).getDB(db);
                } catch (UnknownHostException ex) {
                    throw new ManifoldCFException("GridFS: Given host information is not valid or mongod process doesn't run" + ex.getMessage(), ex);
                }
            } else if (!StringUtils.isEmpty(host) && !StringUtils.isEmpty(port)) {
                try {
                    int integerPort = Integer.parseInt(port);
                    session = new MongoClient(host, integerPort).getDB(db);
                } catch (UnknownHostException ex) {
                    throw new ManifoldCFException("GridFS: Given information is not valid or mongod process doesn't run" + ex.getMessage(), ex);
                } catch (NumberFormatException ex) {
                    throw new ManifoldCFException("GridFS: Given port is not valid number. " + ex.getMessage(), ex);
                }
            } else if (StringUtils.isEmpty(host) && !StringUtils.isEmpty(port)) {
                try {
                    int integerPort = Integer.parseInt(port);
                    session = new MongoClient(host, integerPort).getDB(db);
                } catch (UnknownHostException ex) {
                    throw new ManifoldCFException("GridFS: Given information is not valid or mongod process doesn't run" + ex.getMessage(), ex);
                } catch (NumberFormatException ex) {
                    throw new ManifoldCFException("GridFS: Given port is not valid number. " + ex.getMessage(), ex);
                }
View Full Code Here


import java.net.UnknownHostException;
import java.util.Random;

public class DotNotationTest {
    public static void main(String[] args) throws UnknownHostException {
        MongoClient client = new MongoClient();
        DB db = client.getDB("course");
        DBCollection lines = db.getCollection("DotNotationTest");
        lines.drop();
        Random rand = new Random();

        // insert 10 lines with random start and end points
View Full Code Here

                true, true);
        return (Integer) doc.get("counter") - range + 1;
   }

    private static DBCollection createCollection() throws UnknownHostException {
        MongoClient client = new MongoClient();
        DB db = client.getDB("course");
        return db.getCollection("FindModifyTest");
    }
View Full Code Here

        collection.remove(new BasicDBObject("_id", "frank"));
    }

    private static DBCollection createCollection() throws UnknownHostException {
        MongoClient client = new MongoClient();
        DB db = client.getDB("course");
        DBCollection collection = db.getCollection("UpdateRemoveTest");
        collection.drop();
        return collection;
    }
View Full Code Here

import java.net.UnknownHostException;

public class InsertTest {
    public static void main(String[] args) throws UnknownHostException {
        MongoClient client = new MongoClient();
        DB courseDB = client.getDB("course");
        DBCollection collection = courseDB.getCollection("insertTest");

        collection.drop();

        DBObject doc = new BasicDBObject().append("x", 1);
View Full Code Here

import java.net.UnknownHostException;
import java.util.Random;

public class FieldSelectionTest {
    public static void main(String[] args) throws UnknownHostException {
        MongoClient client = new MongoClient();
        DB db = client.getDB("course");
        DBCollection collection = db.getCollection("fieldSelectionTest");
        collection.drop();
        Random rand = new Random();

        // insert 10 documents with two random integers
View Full Code Here

import java.net.UnknownHostException;
import java.util.Random;

public class FindTest {
    public static void main(String[] args) throws UnknownHostException {
        MongoClient client = new MongoClient();
        DB db = client.getDB("course");
        DBCollection collection = db.getCollection("findTest");
        collection.drop();

        // insert 10 documents with a random integer as the value of field "x"
        for (int i = 0; i < 10; i++) {
View Full Code Here

import java.net.UnknownHostException;
import java.util.Random;

public class FindCriteriaTest {
    public static void main(String[] args) throws UnknownHostException {
        MongoClient client = new MongoClient();
        DB db = client.getDB("course");
        DBCollection collection = db.getCollection("findCriteriaTest");
        collection.drop();

        // insert 10 documents with two random integers
        for (int i = 0; i < 10; i++) {
View Full Code Here

import java.net.UnknownHostException;
import java.util.Random;

public class SortSkipLimitTest {
    public static void main(String[] args) throws UnknownHostException {
        MongoClient client = new MongoClient();
        DB db = client.getDB("course");
        DBCollection lines = db.getCollection("SortSkipLimitTest");
        lines.drop();
        Random rand = new Random();

        // insert 10 lines with random start and end points
View Full Code Here

        collection.remove(new BasicDBObject("_id", "frank"));
    }

    private static DBCollection createCollection() throws UnknownHostException {
        MongoClient client = new MongoClient();
        DB db = client.getDB("students");
        DBCollection collection = db.getCollection("grades");
        //collection.drop();
        return collection;
    }
View Full Code Here

TOP

Related Classes of com.mongodb.MongoClient

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.