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");
}
Aggregations