Class ODatabasePool
java.lang.Object
com.orientechnologies.orient.core.db.ODatabasePool
- All Implemented Interfaces:
AutoCloseable
A Pool of databases.
Example of usage with an OrientDB context:
OrientDB orientDb= new OrientDB("remote:localhost","root","password");
//...
ODatabasePool pool = new ODatabasePool(orientDb,"myDb","admin","adminpwd");
ODatabaseDocument session = pool.acquire();
//....
session.close();
pool.close();
orientDb.close();
Example of usage as simple access to a specific database without a context:
ODatabasePool pool = new ODatabasePool("remote:localhost/myDb","admin","adminpwd");
ODatabaseDocument session = pool.acquire();
//....
session.close();
pool.close();
Created by tglman on 08/02/17.
-
Constructor Summary
ConstructorsConstructorDescriptionODatabasePool(OrientDB environment, String database, String user, String password) Open a new database pool on a specific environment.ODatabasePool(OrientDB environment, String database, String user, String password, OrientDBConfig configuration) Open a new database pool on a specific environment, with a specific configuration for this pool.ODatabasePool(String url, String user, String password) Open a new database pool from a url, useful in case the application access to only a database or do not manipulate databases.ODatabasePool(String url, String user, String password, OrientDBConfig configuration) Open a new database pool from a url and additional configuration, useful in case the application access to only a database or do not manipulate databases.ODatabasePool(String environment, String database, String user, String password) Open a new database pool from a environment and a database name, useful in case the application access to only a database or do not manipulate databases.ODatabasePool(String environment, String database, String user, String password, OrientDBConfig configuration) Open a new database pool from a environment and a database name with a custom configuration, useful in case the application access to only a database or do not manipulate databases. -
Method Summary
-
Constructor Details
-
ODatabasePool
Open a new database pool on a specific environment.- Parameters:
environment- the starting environment.database- the database nameuser- the database user for the current pool of databases.password- the password relative to the user name
-
ODatabasePool
public ODatabasePool(OrientDB environment, String database, String user, String password, OrientDBConfig configuration) Open a new database pool on a specific environment, with a specific configuration for this pool.- Parameters:
environment- the starting environment.database- the database nameuser- the database user for the current pool of databases.password- the password relative to the user nameconfiguration- the configuration relative for the current pool.
-
ODatabasePool
Open a new database pool from a url, useful in case the application access to only a database or do not manipulate databases.- Parameters:
url- the full url for a database, like "embedded:/full/path/to/database" or "remote:localhost/database"user- the database user for the current pool of databases.password- the password relative to the user
-
ODatabasePool
Open a new database pool from a url and additional configuration, useful in case the application access to only a database or do not manipulate databases.- Parameters:
url- the full url for a database, like "embedded:/full/path/to/database" or "remote:localhost/database"user- the database user for the current pool of databases.password- the password relative to the userconfiguration- the configuration relative to the current pool.
-
ODatabasePool
Open a new database pool from a environment and a database name, useful in case the application access to only a database or do not manipulate databases.- Parameters:
environment- the url for an environemnt, like "embedded:/the/environment/path/" or "remote:localhost"database- the database for the current url.user- the database user for the current pool of databases.password- the password relative to the user
-
ODatabasePool
public ODatabasePool(String environment, String database, String user, String password, OrientDBConfig configuration) Open a new database pool from a environment and a database name with a custom configuration, useful in case the application access to only a database or do not manipulate databases.- Parameters:
environment- the url for an environemnt, like "embedded:/the/environment/path/" or "remote:localhost"database- the database for the current url.user- the database user for the current pool of databases.password- the password relative to the userconfiguration- the configuration relative to the current pool.
-
-
Method Details
-
acquire
Acquire a session from the pool, if no session are available will wait until a session is available or a timeout is reached- Returns:
- a session from the pool.
- Throws:
OAcquireTimeoutException- in case the timeout for waiting for a session is reached.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
isClosed
public boolean isClosed()Check if database pool is closed- Returns:
- true if database pool is closed
-