Skip to content

Latest commit

 

History

History
65 lines (45 loc) · 2.1 KB

yugabytedb.md

File metadata and controls

65 lines (45 loc) · 2.1 KB

YugabyteDB Module

See Database containers for documentation and usage that is common to all database container types.

YugabyteDB supports two APIs.

  • Yugabyte Structured Query Language YSQL is a fully-relational API that is built by the PostgreSQL code
  • Yugabyte Cloud Query Language YCQL is a semi-relational SQL API that has its roots in the Cassandra Query Language

Usage example

YSQL API

public class YugabyteDBTest {

    @Rule
    public YugabyteYSQLContainer container = new YugabyteYSQLContainer("yugabytedb/yugabyte:2.9.1.0-b140");
    
    @Test
    public void method() {
        String url = container.getJdbcUrl();

        ... create a connection and run the tests as usual. It also depends on the frameworks being used.

JDBC URL

jdbc:tc:yugabyte:2.7.2.0-b216:///yugabyte

YCQL API

public class YugabyteDBTest {

    @Rule
    public YugabyteYCQLContainer container = new YugabyteYCQLContainer("yugabytedb/yugabyte:2.9.1.0-b140");
    
    @Test
    public void method() {
        Session session = container.getSession();

        ... create a connection and run the tests as usual. It also depends on the frameworks being used.

Adding this module to your project dependencies

Add the following dependency to your pom.xml/build.gradle file:

testImplementation "org.testcontainers:yugabytedb:{{latest_version}}"
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>yugabytedb</artifactId>
    <version>{{latest_version}}</version>
    <scope>test</scope>
</dependency>

!!! hint Adding this Testcontainers library JAR will not automatically add the Yugabytedb driver JAR to your project. You should ensure that your project has the Yugabytedb driver as a dependency, if you plan on using it. Refer to the driver page YSQL and YCQL for instructions.