Class OrientDBObject
java.lang.Object
com.orientechnologies.orient.object.db.OrientDBObject
- All Implemented Interfaces:
AutoCloseable
OrientDB Object management environment, it allow to connect to an environment and manipulate
databases or open sessions.
Usage example:
Remote Example:
OrientDBObject orientDbObject = new OrientDBObject("remote:localhost","root","root");
if(orientDbObject.createIfNotExists("test",ODatabaseType.MEMORY)){
ODatabaseDocument session = orientDbObject.open("test","admin","admin");
session.createClass("MyClass");
session.close();
}
ODatabaseObject session = orientDbObject.open("test","writer","writer");
//...
session.close();
orientDbObject.close();
Embedded example:
OrientDBObject orientDbObject = new OrientDBObject("embedded:./databases/",null,null);
orientDbObject.create("test",ODatabaseType.PLOCAL);
ODatabaseObject session = orientDbObject.open("test","admin","admin");
//...
session.close();
orientDbObject.close();
Database Manipulation Example:
OrientDB orientDbObject = ...
if(!orientDbObject.exists("one")){
orientDbObject.create("one",ODatabaseType.PLOCAL);
}
if(orientDbObject.exists("two")){
orientDbObject.drop("two");
}
List<String> databases = orientDbObject.list();
assertEquals(databases.size(),1);
assertEquals(databases.get("0"),"one");
Created by tglman on 13/01/17.
-
Constructor Summary
ConstructorsConstructorDescriptionOrientDBObject(OrientDB orientDB) Create a new OrientDb Object instance from a givenOrientDBOrientDBObject(String environment, OrientDBConfig config) Create a new OrientDb Object instance for a specific environmentOrientDBObject(String environment, String serverUser, String serverPassword, OrientDBConfig config) Create a new OrientDB Object instance for a specific environment -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidcreate(String name, ODatabaseType type) Create a new databasevoidcreate(String name, ODatabaseType type, OrientDBConfig config) Create a new databasevoidDrop a databasebooleanCheck if a database existsprotected OrientDBlist()List of database exiting in the current environmentOpen a database specified by name using the username and password if neededopen(String name, String user, String password, OrientDBConfig config) Open a database specified by name using the username and password if needed, with specific configuration
-
Constructor Details
-
OrientDBObject
Create a new OrientDb Object instance from a givenOrientDB- Parameters:
orientDB- the given environment.
-
OrientDBObject
Create a new OrientDb Object instance for a specific environmentpossible kind of urls 'embedded','remote', for the case of remote and distributed can be specified multiple nodes using comma.
Remote Example:
OrientDBObject orientDbObject = new OrientDBObject("remote:localhost"); ODatabaseObject session = orientDbObject.open("test","admin","admin"); //... session.close(); orientDbObject.close();Embedded Example:
OrientDBObject orientDbObject = new OrientDBObject("embedded:./databases/"); ODatabaseObject session = orientDbObject.open("test","admin","admin"); //... session.close(); orientDbObject.close();- Parameters:
environment- the url for the specific environment.config- configuration for the specific environment for the list of option .
-
OrientDBObject
public OrientDBObject(String environment, String serverUser, String serverPassword, OrientDBConfig config) Create a new OrientDB Object instance for a specific environmentpossible kind of urls 'embedded','remote', for the case of remote and distributed can be specified multiple nodes using comma.
Remote Example:
OrientDBObject orientDbObject = new OrientDBObject("remote:localhost","root","root"); orientDbObject.create("test",ODatabaseType.PLOCAL); ODatabaseObject session = orientDbObject.open("test","admin","admin"); //... session.close(); orientDbObject.close();Embedded Example:
OrientDBObject orientDbObject = new OrientDBObject("embedded:./databases/",null,null); orientDbObject.create("test",ODatabaseType.MEMORY); ODatabaseObject session = orientDbObject.open("test","admin","admin"); //... session.close(); orientDbObject.close();- Parameters:
environment- the url for the specific environment.serverUser- the server user allowed to manipulate databases.serverPassword- relative to the server user.config- configuration for the specific environment for the list of option .
-
-
Method Details
-
open
Open a database specified by name using the username and password if needed- Parameters:
name- of the database to openuser- the username allowed to open the databasepassword- related to the specified username- Returns:
- the opened database
-
open
Open a database specified by name using the username and password if needed, with specific configuration- Parameters:
name- of the database to openuser- the username allowed to open the databasepassword- related to the specified usernameconfig- database specific configuration that override the orientDB global settings where needed.- Returns:
- the opened database
-
create
Create a new database- Parameters:
name- database nametype- can be plocal or memory
-
create
Create a new database- Parameters:
name- database nametype- can be plocal or memoryconfig- database specific configuration that override the orientDB global settings where needed.
-
execute
-
execute
-
exists
Check if a database exists- Parameters:
name- database name to check- Returns:
- boolean true if exist false otherwise.
-
drop
Drop a database- Parameters:
name- database name
-
list
List of database exiting in the current environment- Returns:
- a set of databases names.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getOrientDB
-