public abstract class JdbcDatabaseContainer
extends org.testcontainers.containers.GenericContainer
| Constructor and Description |
|---|
JdbcDatabaseContainer(Future<String> image) |
JdbcDatabaseContainer(String dockerImageName) |
| Modifier and Type | Method and Description |
|---|---|
protected String |
constructUrlForConnection(String queryString)
Template method for constructing the JDBC URL to be used for creating
Connections. |
Connection |
createConnection(String queryString)
Creates a connection to the underlying containerized database instance.
|
String |
getDatabaseName() |
DataSource |
getDataSource() |
abstract String |
getDriverClassName() |
Driver |
getJdbcDriverInstance()
Obtain an instance of the correct JDBC driver for this particular database container type.
|
abstract String |
getJdbcUrl() |
abstract String |
getPassword() |
protected int |
getStartupTimeoutSeconds() |
protected abstract String |
getTestQueryString() |
abstract String |
getUsername() |
protected void |
waitUntilContainerStarted() |
JdbcDatabaseContainer |
withConnectTimeoutSeconds(int connectTimeoutSeconds)
Set time to allow for the database to start and establish an initial connection, in seconds.
|
JdbcDatabaseContainer |
withDatabaseName(String dbName) |
JdbcDatabaseContainer |
withPassword(String password) |
JdbcDatabaseContainer |
withStartupTimeoutSeconds(int startupTimeoutSeconds)
Set startup time to allow, including image pull time, in seconds.
|
JdbcDatabaseContainer |
withUsername(String username) |
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, configure, containerIsCreated, containerIsStarted, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, copyFileFromContainer, copyFileToContainer, copyFileToContainer, createVolumeDirectory, dependsOn, dependsOn, doStart, equals, execInContainer, execInContainer, failed, fetchDockerDaemonInfo, finished, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerDaemonInfo, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPortNumbers, getLivenessCheckPorts, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, hashCode, isPrivilegedMode, logger, setBinds, setCommand, setCommand, setCommandParts, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, starting, stop, succeeded, toString, waitingFor, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectoryclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBindpublic JdbcDatabaseContainer(String dockerImageName)
public abstract String getDriverClassName()
public abstract String getJdbcUrl()
public String getDatabaseName()
public abstract String getUsername()
public abstract String getPassword()
protected abstract String getTestQueryString()
public JdbcDatabaseContainer withUsername(String username)
public JdbcDatabaseContainer withPassword(String password)
public JdbcDatabaseContainer withDatabaseName(String dbName)
public JdbcDatabaseContainer withStartupTimeoutSeconds(int startupTimeoutSeconds)
startupTimeoutSeconds - startup time to allow, including image pull time, in secondspublic JdbcDatabaseContainer withConnectTimeoutSeconds(int connectTimeoutSeconds)
connectTimeoutSeconds - time to allow for the database to start
and establish an initial connection in secondsprotected void waitUntilContainerStarted()
waitUntilContainerStarted in class org.testcontainers.containers.GenericContainerpublic Driver getJdbcDriverInstance()
public Connection createConnection(String queryString) throws SQLException
queryString - query string parameters that should be appended to the JDBC connection URL.
The '?' character must be includedSQLException - if there is a repeated failure to create the connectionpublic DataSource getDataSource()
protected String constructUrlForConnection(String queryString)
Connections.
This should be overridden if the JDBC URL and query string concatenation or URL string
construction needs to be different to normal.queryString - query string parameters that should be appended to the JDBC connection URL.
The '?' character must be includedprotected int getStartupTimeoutSeconds()
Copyright © 2019 WSO2. All rights reserved.