public class OrientDBObject extends Object implements AutoCloseable
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 and Description |
---|
OrientDBObject(OrientDB orientDB)
Create a new OrientDb Object instance from a given
OrientDB |
OrientDBObject(String environment,
OrientDBConfig config)
Create a new OrientDb Object instance for a specific environment
|
OrientDBObject(String environment,
String serverUser,
String serverPassword,
OrientDBConfig config)
Create a new OrientDB Object instance for a specific environment
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
create(String name,
ODatabaseType type)
Create a new database
|
void |
create(String name,
ODatabaseType type,
OrientDBConfig config)
Create a new database
|
void |
drop(String name)
Drop a database
|
boolean |
exists(String name)
Check if a database exists
|
protected OrientDB |
getOrientDB() |
List<String> |
list()
List of database exiting in the current environment
|
ODatabaseObject |
open(String name,
String user,
String password)
Open a database specified by name using the username and password if needed
|
ODatabaseObject |
open(String name,
String user,
String password,
OrientDBConfig config)
Open a database specified by name using the username and password if needed, with specific
configuration
|
public OrientDBObject(OrientDB orientDB)
OrientDB
orientDB
- the given environment.public OrientDBObject(String environment, OrientDBConfig config)
possible 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();
environment
- the url for the specific environment.config
- configuration for the specific environment for the list of option OGlobalConfiguration
.public OrientDBObject(String environment, String serverUser, String serverPassword, OrientDBConfig config)
possible 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();
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 OGlobalConfiguration
.public ODatabaseObject open(String name, String user, String password)
name
- of the database to openuser
- the username allowed to open the databasepassword
- related to the specified usernamepublic ODatabaseObject open(String name, String user, String password, OrientDBConfig config)
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.public void create(String name, ODatabaseType type)
name
- database nametype
- can be plocal or memorypublic void create(String name, ODatabaseType type, OrientDBConfig config)
name
- database nametype
- can be plocal or memoryconfig
- database specific configuration that override the orientDB global settings where
needed.public boolean exists(String name)
name
- database name to checkpublic void drop(String name)
name
- database namepublic List<String> list()
public void close()
close
in interface AutoCloseable
protected OrientDB getOrientDB()
Copyright © 2009–2020 OrientDB. All rights reserved.