Example usage for com.mongodb Mongo dropDatabase

List of usage examples for com.mongodb Mongo dropDatabase

Introduction

In this page you can find the example usage for com.mongodb Mongo dropDatabase.

Prototype

public void dropDatabase(final String dbName) 

Source Link

Document

Drops the database if it exists.

Usage

From source file:org.ossmeter.platform.app.example.ResetApp.java

License:Open Source License

public static void main(String[] args) throws Exception {

    Mongo mongo = new Mongo();
    mongo.dropDatabase("ossmeter");
    mongo.dropDatabase("pdb_values");
    mongo.dropDatabase("pongo");
    mongo.dropDatabase("fedora");
    mongo.dropDatabase("epsilon");
    mongo.dropDatabase("Epsilon");
    mongo.dropDatabase("hamcrest");
    mongo.dropDatabase("jMonkeyEngine");
    mongo.dropDatabase("thunderbird");
    mongo.dropDatabase("fedora");
    mongo.dropDatabase("saf");
    mongo.dropDatabase("mojambo-grit");
    mongo.dropDatabase("emf");
    mongo.dropDatabase("xText");
    mongo.dropDatabase("toolsEmf");
    mongo.dropDatabase("eclipsePlatform");
    mongo.dropDatabase("pdb_values");
    mongo.dropDatabase("pongo");
    mongo.dropDatabase("modelinggmt");
    mongo.dropDatabase("eclipse");
    mongo.dropDatabase("modelinggmtamw");
    mongo.dropDatabase("Log4J");
    mongo.dropDatabase("BIRT");
    mongo.dropDatabase("SiriusForum");
}

From source file:pl.nask.hsn2.os.MongoConnector.java

License:Open Source License

private MongoConnector(String host, int port) throws IOException {
    Mongo mongo = null;
    try {/* ww w . ja va  2  s . c o  m*/
        mongo = new Mongo(host, port);
        mongo.dropDatabase("object-store");
        db = mongo.getDB("object-store");
        collection = db.createCollection("allJobsInOne", null);
        collection.ensureIndex(new BasicDBObject("parent", 1));
    } catch (UnknownHostException e) {
        LOGGER.error("MongoDB host is unreachable: {}", e.getMessage());
        throw new IOException("MongoDB is unreachable", e);
    } catch (MongoException.Network e) {
        LOGGER.error("Couldn't connect to MongoDB: {}", e.getMessage());
        throw new IOException("MongoDB is unreachable", e);
    }
}