Skip to content

TriCoreDB for Java

0.1.0

The official Java client: SQL, documents, cache, vectors and graphs over one native connection.

Install

Maven
<dependency>
  <groupId>com.tricoredb</groupId>
  <artifactId>tricoredb</artifactId>
  <version>0.1.0</version>
</dependency>
Gradle (Kotlin DSL)
implementation("com.tricoredb:tricoredb:0.1.0")

Requirements

  • Java 17 or later
  • A TriCoreDB server, 0.1.0-rc.1 or later (install one)

Highlights

  • No runtime dependencies beyond the JDK
  • AutoCloseable connections and a Pool
  • Exact BigDecimal values
  • Transactions, TLS and mutual TLS

Quick start

Main.java
import com.tricoredb.Rows;
import com.tricoredb.TriCore;
import java.util.List;

try (TriCore db = TriCore.connect("127.0.0.1", 8427, "admin", "your-password")) {
    db.execute("CREATE TABLE IF NOT EXISTS users (id INT PRIMARY KEY, name TEXT)");
    db.execute("INSERT INTO users VALUES (?, ?)", List.of(1, "O'Hara"), "main");

    Rows rows = db.query("SELECT id, name FROM users WHERE id = ?", List.of(1), "main");
    System.out.println(rows.asMaps()); // [{id=1, name=O'Hara}]
}

TLS

This example connects without TLS, which matches the development container. The default image requires TLS. The README shows how to connect with a CA certificate, and documents every call.