Package io.narayana.db
Class Allocator
java.lang.Object
io.narayana.db.Allocator
- Direct Known Subclasses:
CIPostgreAllocator,DBAllocator,ExternalDBAllocator,H2Allocator,PostgreContainerAllocator
Start databases according to the profile. The goal is to be able to work both with platform
independent simple H2 example, locally started databases in containers, e.g. Postgres, and
with remote databases configured via REST API, e.g. MS SQL, Oracle, Maria and more.
- Author:
- Michal Karm Babacek
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract DBabstract DBallocateDB(int expiryMinutes) abstract booleanabstract booleandeallocateDB(DB db) static booleanexecuteTestStatement(DB db, String pathToDriverJar) Loads proper driver dynamically.static Allocatorstatic Stringabstract booleanreallocateDB(int expiryMinutes, DB db) abstract booleanreallocateDB(DB db)
-
Constructor Details
-
Allocator
public Allocator()
-
-
Method Details
-
getInstance
- Throws:
IOException
-
allocateDB
-
allocateDB
-
deallocateDB
-
reallocateDB
-
reallocateDB
-
cleanDB
-
executeTestStatement
public static boolean executeTestStatement(DB db, String pathToDriverJar) throws ClassNotFoundException, MalformedURLException, IllegalAccessException, InstantiationException, SQLException Loads proper driver dynamically. Credit: http://www.kfu.com/%7Ensayer/Java/dyn-jdbc.htmlExecutes a simple SELECT 1 statement to verify the DB actually does something.
- Parameters:
db- , used as: dbUrl JDBC connection URL user DB user pass DB password driverClass e.g. org.postgresql.Driver pathToDriverJar Either a downloaded driver jar or a one from ShrinkWrap Maven resolver overallTimeoutMs How long do we keep trying with 1000ms pause in between- Returns:
- true on success
- Throws:
ClassNotFoundException- Fix the driver class nameMalformedURLException- Fix the driver jar pathIllegalAccessExceptionInstantiationExceptionSQLException
-
getProp
-