Package nl.cwi.monetdb.embedded.env
Class MonetDBEmbeddedDatabase
java.lang.Object
nl.cwi.monetdb.embedded.env.MonetDBEmbeddedDatabase
public final class MonetDBEmbeddedDatabase extends Object
An embedded version of a MonetDB database.
Communication between Java and native C is done via JNI. The MonetDB's JNI library must be successfully loaded in
order to the other methods work.
Note: You can have only one Embedded MonetDB database running per JVM process.
Note: You can have only one Embedded MonetDB database running per JVM process.
- Author:
- Pedro Ferreira
-
Method Summary
Modifier and Type Method Description static MonetDBEmbeddedConnectioncreateConnection()Creates a connection on the database, set on the default schema.static JDBCEmbeddedConnectioncreateJDBCEmbeddedConnection(String directory)Creates a JDBC embedded connection in the directory.static JDBCEmbeddedConnectioncreateJDBCEmbeddedConnection(String directory, boolean silentFlag, boolean sequentialFlag)Creates a JDBC embedded connection in the directory.static StringgetDatabaseDirectory()Gets the database's farm directory.static intgetNumberOfConnections()Gets the current total number of connections to the database.static booleanisDatabaseRunning()Check if the database is still running or not.static booleanisDatabaseRunningInMemory()Check if the database is running in-memory.static booleanisSequentialFlagSet()Checks if the Sequential Flag was set while creating the database.static booleanisSilentFlagSet()Checks if the Silent Flag was set while creating the database.static voidremoveConnection(MonetDBEmbeddedConnection con, boolean toShutDown)Removes a connection from the database.static voidstartDatabase(String dbDirectory)Starts a MonetDB database on the given farm.static voidstartDatabase(String dbDirectory, boolean silentFlag, boolean sequentialFlag)Starts a MonetDB database on the given farm with debugging parameters if desired.static voidstopDatabase()Stops the database.
-
Method Details
-
isDatabaseRunning
public static boolean isDatabaseRunning()Check if the database is still running or not.- Returns:
- A boolean indicating if the database is running
-
isDatabaseRunningInMemory
Check if the database is running in-memory.- Returns:
- A boolean indicating if the database is running in-memory
- Throws:
MonetDBEmbeddedException- If the database is not running
-
startDatabase
public static void startDatabase(String dbDirectory, boolean silentFlag, boolean sequentialFlag) throws MonetDBEmbeddedExceptionStarts a MonetDB database on the given farm with debugging parameters if desired. This method should be used by experts only :)- Parameters:
dbDirectory- The full path of the farmsilentFlag- A boolean if silent mode will be turned on or notsequentialFlag- A boolean indicating if the sequential pipeline will be set or not- Throws:
MonetDBEmbeddedException- If the JNI library has not been loaded yet or an error in the database occurred
-
startDatabase
Starts a MonetDB database on the given farm.- Parameters:
dbDirectory- The full path of the farm- Throws:
MonetDBEmbeddedException- If the JNI library has not been loaded yet or an error in the database occurred
-
getDatabaseDirectory
Gets the database's farm directory.- Returns:
- A String representing the database's farm directory
- Throws:
MonetDBEmbeddedException- If the database is not running
-
getNumberOfConnections
Gets the current total number of connections to the database.- Returns:
- The total number of connections to the database
- Throws:
MonetDBEmbeddedException- If the database is not running
-
isSilentFlagSet
Checks if the Silent Flag was set while creating the database.- Returns:
- The Silent Flag
- Throws:
MonetDBEmbeddedException- If the database is not running
-
isSequentialFlagSet
Checks if the Sequential Flag was set while creating the database.- Returns:
- The Sequential Flag
- Throws:
MonetDBEmbeddedException- If the database is not running
-
stopDatabase
Stops the database. All the pending connections will be shut down as well.- Throws:
MonetDBEmbeddedException- If the database is not running or an error in the database occurred
-
createConnection
Creates a connection on the database, set on the default schema.- Returns:
- A MonetDBEmbeddedConnection instance
- Throws:
MonetDBEmbeddedException- If the database is not running or an error in the database occurred
-
createJDBCEmbeddedConnection
public static JDBCEmbeddedConnection createJDBCEmbeddedConnection(String directory, boolean silentFlag, boolean sequentialFlag) throws MonetDBEmbeddedExceptionCreates a JDBC embedded connection in the directory.- Parameters:
directory- The full path of the farmsilentFlag- A boolean if silent mode will be turned on or notsequentialFlag- A boolean indicating if the sequential pipeline will be set or not- Returns:
- A JDBCEmbeddedConnection instance
- Throws:
MonetDBEmbeddedException- If the database is not running or an error in the database occurred
-
createJDBCEmbeddedConnection
public static JDBCEmbeddedConnection createJDBCEmbeddedConnection(String directory) throws MonetDBEmbeddedExceptionCreates a JDBC embedded connection in the directory.- Parameters:
directory- The full path of the farm- Returns:
- A JDBCEmbeddedConnection instance
- Throws:
MonetDBEmbeddedException- If the database is not running or an error in the database occurred
-
removeConnection
public static void removeConnection(MonetDBEmbeddedConnection con, boolean toShutDown) throws MonetDBEmbeddedExceptionRemoves a connection from the database.- Parameters:
con- The connection to removetoShutDown- If true, if there are no more connections in the database after the removal, the database is shut down.- Throws:
MonetDBEmbeddedException- If the database is not running or an error in the database occurred
-