
public class OrientDB extends Object implements AutoCloseable
Usage example:
Remote Example:
OrientDB orientDb = new OrientDB("remote:localhost","root","root");
if(orientDb.createIfNotExists("test",ODatabaseType.MEMORY)){
ODatabaseDocument session = orientDb.open("test","admin","admin");
session.createClass("MyClass");
session.close();
}
ODatabaseDocument session = orientDb.open("test","writer","writer");
//...
session.close();
orientDb.close();
Embedded example:
OrientDB orientDb = new OrientDB("embedded:./databases/",null,null);
orientDb.create("test",ODatabaseType.PLOCAL);
ODatabaseDocument session = orientDb.open("test","admin","admin");
//...
session.close();
orientDb.close();
Database Manipulation Example:
OrientDB orientDb = ...
if(!orientDb.exists("one")){
orientDb.create("one",ODatabaseType.PLOCAL);
}
if(orientDb.exists("two")){
orientDb.drop("two");
}
List<String> databases = orientDb.list();
assertEquals(databases.size(),1);
assertEquals(databases.get("0"),"one");
Created by tglman on 08/02/17.
| Modifier and Type | Field and Description |
|---|---|
protected OrientDBInternal |
internal |
| Constructor and Description |
|---|
OrientDB(String url,
OrientDBConfig configuration)
Create a new OrientDb instance for a specific environment
possible kind of urls 'embedded','remote', for the case of remote and distributed can be specified multiple nodes
using comma.
|
OrientDB(String url,
String serverUser,
String serverPassword,
OrientDBConfig configuration)
Create a new OrientDb instance for a specific environment
possible kind of urls 'embedded','remote', for the case of remote and distributed can be specified multiple nodes
using comma.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the current OrientDB context with all related databases and pools.
|
void |
create(String database,
ODatabaseType type)
Create a new database
|
void |
create(String database,
ODatabaseType type,
OrientDBConfig config)
Create a new database
|
boolean |
createIfNotExists(String database,
ODatabaseType type)
Create a new database if not exists
|
boolean |
createIfNotExists(String database,
ODatabaseType type,
OrientDBConfig config)
Create a new database if not exists
|
void |
drop(String database)
Drop a database
|
boolean |
exists(String database)
Check if a database exists
|
boolean |
isOpen()
Check if the current OrientDB context is open
|
List<String> |
list()
List exiting databases in the current environment
|
ODatabaseSession |
open(String database,
String user,
String password)
Open a database
|
ODatabaseSession |
open(String database,
String user,
String password,
OrientDBConfig config)
Open a database
|
protected OrientDBInternal internal
public OrientDB(String url, OrientDBConfig configuration)
Remote Example:
OrientDB orientDb = new OrientDB("remote:localhost");
ODatabaseDocument session = orientDb.open("test","admin","admin");
//...
session.close();
orientDb.close();
Embedded Example:
OrientDB orientDb = new OrientDB("embedded:./databases/");
ODatabaseDocument session = orientDb.open("test","admin","admin");
//...
session.close();
orientDb.close();
url - the url for the specific environment.configuration - configuration for the specific environment for the list of option OGlobalConfiguration.public OrientDB(String url, String serverUser, String serverPassword, OrientDBConfig configuration)
Remote Example:
OrientDB orientDb = new OrientDB("remote:localhost","root","root");
orientDb.create("test",ODatabaseType.PLOCAL);
ODatabaseDocument session = orientDb.open("test","admin","admin");
//...
session.close();
orientDb.close();
Embedded Example:
OrientDB orientDb = new OrientDB("embedded:./databases/",null,null);
orientDb.create("test",ODatabaseType.MEMORY);
ODatabaseDocument session = orientDb.open("test","admin","admin");
//...
session.close();
orientDb.close();
url - the url for the specific environment.serverUser - the server user allowed to manipulate databases.serverPassword - relative to the server user.configuration - configuration for the specific environment for the list of option OGlobalConfiguration.public ODatabaseSession open(String database, String user, String password)
database - the database to openuser - username of a database user or a server user allowed to open the databasepassword - related to the specified usernamepublic ODatabaseSession open(String database, String user, String password, OrientDBConfig config)
database - the database to openuser - username of a database user or a server user allowed to open the databasepassword - related to the specified usernameconfig - custom configuration for current databasepublic void create(String database, ODatabaseType type)
database - database nametype - can be plocal or memorypublic void create(String database, ODatabaseType type, OrientDBConfig config)
database - database nametype - can be plocal or memoryconfig - custom configuration for current databasepublic boolean createIfNotExists(String database, ODatabaseType type)
database - database nametype - can be plocal or memorypublic boolean createIfNotExists(String database, ODatabaseType type, OrientDBConfig config)
database - database nametype - can be plocal or memoryconfig - custom configuration for current databasepublic void drop(String database)
database - database namepublic boolean exists(String database)
database - database name to checkpublic List<String> list()
public void close()
close in interface AutoCloseablepublic boolean isOpen()
Copyright © 2009–2025 OrientDB. All rights reserved.