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
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder template.static final classCreate newDatabaseManagerinstances. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Returns aDatabaseInfoinstance that describes a database.Return theEmbeddedPostgresinstance 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.
-
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:
closein interfaceAutoCloseable- Throws:
Exception
-
getDatabaseInfo
Returns aDatabaseInfoinstance 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
DatabaseInfoinstance. This is never null. - Throws:
SQLException- Any error that happened during the database creation is thrown here.
-
getEmbeddedPostgres
Return theEmbeddedPostgresinstance that manages the database server which holds all of the databases managed by this database manager.- Returns:
- An
EmbeddedPostgresinstance. Never null.
-