Class ContainerDatabaseDriver
- All Implemented Interfaces:
Driver
jdbc:tc:type://host:port/database?querystring
where type is a supported database type (e.g. mysql, postgresql, oracle). Behind the scenes a new docker container will be launched running the required database engine. New JDBC connections will be created using the database's standard driver implementation, connected to the container.
If TC_INITSCRIPT is set in querystring, it will be used as the path for an init script that
should be run to initialize the database after the container is created. This should be a classpath resource.
Similarly TC_INITFUNCTION may be a method reference for a function that can initialize the database.
Such a function must accept a javax.sql.Connection as its only parameter.
An example of a valid method reference would be com.myapp.SomeClass::initFunction
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptsURL(String url) connect(String url, Properties info) intintgetPropertyInfo(String url, Properties info) booleanstatic voidkillContainer(String jdbcUrl) Utility method to kill a database container directly from test support code.static voidUtility method to kill ALL database containers directly from test support code.
-
Constructor Details
-
ContainerDatabaseDriver
public ContainerDatabaseDriver()
-
-
Method Details
-
acceptsURL
- Specified by:
acceptsURLin interfaceDriver- Throws:
SQLException
-
connect
- Specified by:
connectin interfaceDriver- Throws:
SQLException
-
getPropertyInfo
- Specified by:
getPropertyInfoin interfaceDriver- Throws:
SQLException
-
getMajorVersion
public int getMajorVersion()- Specified by:
getMajorVersionin interfaceDriver
-
getMinorVersion
public int getMinorVersion()- Specified by:
getMinorVersionin interfaceDriver
-
jdbcCompliant
public boolean jdbcCompliant()- Specified by:
jdbcCompliantin interfaceDriver
-
getParentLogger
- Specified by:
getParentLoggerin interfaceDriver- Throws:
SQLFeatureNotSupportedException
-
killContainers
public static void killContainers()Utility method to kill ALL database containers directly from test support code. It shouldn't be necessary to use this, but it is provided for convenience - e.g. for situations where many different database containers are being tested and cleanup is needed to limit resource usage. -
killContainer
Utility method to kill a database container directly from test support code. It shouldn't be necessary to use this, but it is provided for convenience - e.g. for situations where many different database containers are being tested and cleanup is needed to limit resource usage.- Parameters:
jdbcUrl- the JDBC URL of the container which should be killed
-