Skip to main content
Version: 3.12

Run Transactions Through the ScalarDB Core Library

This guide explains how to configure your ScalarDB properties file and create schemas to run transactions through a one-phase or a two-phase commit interface by using the ScalarDB core library.

Preparation

For the purpose of this guide, you will set up a database and ScalarDB by using a sample in the ScalarDB samples repository.

Clone the ScalarDB samples repository

Open Terminal, then clone the ScalarDB samples repository by running the following command:

git clone https://github.com/scalar-labs/scalardb-samples

Then, go to the directory that contains the necessary files by running the following command:

cd scalardb-samples/scalardb-sample

Set up a database

Select your database, and follow the instructions to configure it for ScalarDB.

For a list of databases that ScalarDB supports, see Databases.

Run MySQL locally

You can run MySQL in Docker Compose by using the docker-compose.yml file in the scalardb-samples/scalardb-sample directory.

To start MySQL, run the following command:

docker compose up -d mysql

Configure ScalarDB

The database.properties file in the scalardb-samples/scalardb-sample directory contains database configurations for ScalarDB. Please uncomment the properties for MySQL in the database.properties file so that the configuration looks as follows:

# For MySQL
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:mysql://localhost:3306/
scalar.db.username=root
scalar.db.password=mysql

For a comprehensive list of configurations for ScalarDB, see ScalarDB Configurations.

Create or import a schema

ScalarDB has its own data model and schema that maps to the implementation-specific data model and schema.

Run transactions by using Java