Search in sources :

Example 46 with OServerAdmin

use of com.orientechnologies.orient.client.remote.OServerAdmin in project orientdb by orientechnologies.

the class OConsoleDatabaseApp method dropDatabase.

@ConsoleCommand(description = "Delete the specified database", onlineHelp = "Console-Command-Drop-Database")
public void dropDatabase(@ConsoleParameter(name = "database-url", description = "The url of the database to drop in the format '<mode>:<path>'") String iDatabaseURL, @ConsoleParameter(name = "user", description = "Server administrator name") String iUserName, @ConsoleParameter(name = "password", description = "Server administrator password") String iUserPassword, @ConsoleParameter(name = "storage-type", description = "Storage type of server database", optional = true) String storageType) throws IOException {
    if (iDatabaseURL.startsWith(OEngineRemote.NAME)) {
        // REMOTE CONNECTION
        final String dbURL = iDatabaseURL.substring(OEngineRemote.NAME.length() + 1);
        if (serverAdmin != null)
            serverAdmin.close();
        serverAdmin = new OServerAdmin(dbURL).connect(iUserName, iUserPassword);
        serverAdmin.dropDatabase(storageType);
        disconnect();
    } else {
        // LOCAL CONNECTION
        currentDatabase = new ODatabaseDocumentTx(iDatabaseURL);
        if (currentDatabase.exists()) {
            currentDatabase.open(iUserName, iUserPassword);
            currentDatabase.drop();
        } else
            message("\n\nCannot drop database '" + iDatabaseURL + "' because was not found");
    }
    currentDatabase = null;
    currentDatabaseName = null;
    message("\n\nDatabase '" + iDatabaseURL + "' deleted successfully");
}
Also used : ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OServerAdmin(com.orientechnologies.orient.client.remote.OServerAdmin) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Aggregations

OServerAdmin (com.orientechnologies.orient.client.remote.OServerAdmin)46 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)9 Before (org.junit.Before)9 OServer (com.orientechnologies.orient.server.OServer)8 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)6 IOException (java.io.IOException)5 Test (org.testng.annotations.Test)5 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)4 ONeedRetryException (com.orientechnologies.common.concur.ONeedRetryException)3 ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)3 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)3 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)2 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)2 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)2 OConcurrentModificationException (com.orientechnologies.orient.core.exception.OConcurrentModificationException)2 AfterMethod (org.testng.annotations.AfterMethod)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 ORemoteConnectionManager (com.orientechnologies.orient.client.remote.ORemoteConnectionManager)1 OCommandScript (com.orientechnologies.orient.core.command.script.OCommandScript)1 OPartitionedDatabasePool (com.orientechnologies.orient.core.db.OPartitionedDatabasePool)1