public class ContainerDatabaseDriver
extends java.lang.Object
implements java.sql.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 and Description |
|---|
ContainerDatabaseDriver() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsURL(java.lang.String url) |
java.sql.Connection |
connect(java.lang.String url,
java.util.Properties info) |
int |
getMajorVersion() |
int |
getMinorVersion() |
java.util.logging.Logger |
getParentLogger() |
java.sql.DriverPropertyInfo[] |
getPropertyInfo(java.lang.String url,
java.util.Properties info) |
boolean |
jdbcCompliant() |
static void |
killContainer(java.lang.String jdbcUrl)
Utility method to kill a database container directly from test support code.
|
static void |
killContainers()
Utility method to kill ALL database containers directly from test support code.
|
public boolean acceptsURL(java.lang.String url)
throws java.sql.SQLException
acceptsURL in interface java.sql.Driverjava.sql.SQLExceptionpublic java.sql.Connection connect(java.lang.String url,
java.util.Properties info)
throws java.sql.SQLException
connect in interface java.sql.Driverjava.sql.SQLExceptionpublic java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url,
java.util.Properties info)
throws java.sql.SQLException
getPropertyInfo in interface java.sql.Driverjava.sql.SQLExceptionpublic int getMajorVersion()
getMajorVersion in interface java.sql.Driverpublic int getMinorVersion()
getMinorVersion in interface java.sql.Driverpublic boolean jdbcCompliant()
jdbcCompliant in interface java.sql.Driverpublic java.util.logging.Logger getParentLogger()
throws java.sql.SQLFeatureNotSupportedException
getParentLogger in interface java.sql.Driverjava.sql.SQLFeatureNotSupportedExceptionpublic static void killContainers()
public static void killContainer(java.lang.String jdbcUrl)
jdbcUrl - the JDBC URL of the container which should be killed