Java API - OServer

This class allows you to embed and manage a server instance within your application. Once you start the server, you can interact with it and manage data the same as you would standard instances of the OrientDB Server.

For more information, see Embedding the Server. For the complete OServer documentation, see the Javadocs.

Working with OServer

In order to operate on an OrientDB database, you first need to establish a connection with the server. You have two options in this: you can connect to a running OrientDB Server using OrientDB or you can embed the server within your application using this class. It can be found at com.orientechnologies.orient.server. For instance,

/* Import OrientDB Classes */
import com.orientechnologies.orient.server.OServer;

Once you've imported the class to your application, you can use one of the constructors to build a particular instance in your code.


This class provides two constructors to create instances of OServer in your application. The first takes no arguments and the second takes a single boolean argument, which defines whether you want to shut the server down on exit.


OServer(boolean shutdownEngineOnExit)


This class throws the following exceptions.


Once you've initialized the class in your application, you can call the following methods on your instance.

Managing Server Instances

MethodReturn TypeDescription
getInstance()OServerRetrieves a server instance by ID.
getInstanceByPath()OServerRetrieve a server instance by its path.
isActive()booleanChecks whether server is active.
restart()voidRestarts the server.
shutdown()booleanShuts down the server.
startup()OServerStarts the server.

Managing Databases

MethodReturn TypeDescription
getDatabaseDirectory()java.lang.StringRetrieves the root database directory.
openDatabase()ODatabase<T>Opens the given database.

Managing Storage

MethodReturn TypeDescription
existsStoragePath()booleanDetermines whether storage path exists.
getAvailableStorageNames()Map<String, String>Retrieves a map of available storage types.
getStoragePath()java.lang.StringRetrieves the storage path.

User Management

MethodReturn TypeDescription
addTemporaryUser()voidAdds a temporary user to the server.
addUser()voidAdds a user to the server.
authenticate()booleanAuthenticates a user on the server.
dropUser()voidRemoves user from the server.
isAllowed()booleanChecks whether user can access a given resource.


MethodReturn TypeDescription
getConfiguration()OServerConfigurationRetrieves the server configuration.
saveConfiguration()voidSaves the server configuration to disk.