Class DatabaseManager
java.lang.Object
de.softwareforge.testing.postgres.embedded.DatabaseManager
- All Implemented Interfaces:
AutoCloseable
Controls database instances on a PostgreSQL server instances.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder template.static final class
Create newDatabaseManager
instances. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Returns aDatabaseInfo
instance that describes a database.Return theEmbeddedPostgres
instance that manages the database server which holds all of the databases managed by this database manager.Creates a newDatabaseManager.Builder<DatabaseManager>
instance that will create a new database on each call togetDatabaseInfo()
.Creates a newDatabaseManager.Builder<DatabaseManager>
instance that will return a connection to the same database on each call togetDatabaseInfo()
.start()
Start the database server and the machinery that will provide new database instances.
-
Field Details
-
LOG
-
-
Method Details
-
multiDatabases
Creates a newDatabaseManager.Builder<DatabaseManager>
instance that will create a new database on each call togetDatabaseInfo()
.- Returns:
- A builder instance.
-
singleDatabase
Creates a newDatabaseManager.Builder<DatabaseManager>
instance that will return a connection to the same database on each call togetDatabaseInfo()
.- Returns:
- A builder instance.
-
start
Start the database server and the machinery that will provide new database instances.- Returns:
- This object.
- Throws:
IOException
- The server could not be started.SQLException
- A SQL problem occured while trying to initialize the database.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
getDatabaseInfo
Returns aDatabaseInfo
instance that describes a database. If this database provider is in multi mode, every call to this method will return a new database instance. If it is in single mode, it will always return the same database instance.- Returns:
- A
DatabaseInfo
instance. This is never null. - Throws:
SQLException
- Any error that happened during the database creation is thrown here.
-
getEmbeddedPostgres
Return theEmbeddedPostgres
instance that manages the database server which holds all of the databases managed by this database manager.- Returns:
- An
EmbeddedPostgres
instance. Never null.
-