Class ContainerDatabaseDriver

java.lang.Object
org.testcontainers.jdbc.ContainerDatabaseDriver
All Implemented Interfaces:
Driver

public class ContainerDatabaseDriver extends Object implements Driver
Test Containers JDBC proxy driver. This driver will handle JDBC URLs of the form:

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 Details

    • ContainerDatabaseDriver

      public ContainerDatabaseDriver()
  • Method Details