Run Non-Transactional Storage Operations Through the SQL Interface
This guide explains how to run non-transactional storage operations through the SQL interface for ScalarDB Cluster.
You need to have a license key (trial license or commercial license) for ScalarDB Cluster. If you don't have a license key, please contact us.
Preparation​
For the purpose of this guide, you will set up a database and ScalarDB Cluster in standalone mode by using a sample in the ScalarDB samples repository.
ScalarDB Cluster in standalone mode is primarily for development and testing purposes.
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-cluster-standalone-mode
Set up a database​
Follow the instructions below to configure your database for ScalarDB Cluster.
For a list of databases that ScalarDB supports, see Databases.
- Relational databases
- NewSQL databases
- NoSQL databases
- Object storage
Select your relational database.
- Db2
- MariaDB
- MySQL
- Oracle Database
- PostgreSQL
- SQL Server
Run Db2 locally
You can run IBM Db2 in Docker Compose by using the docker-compose.yml file in the scalardb-samples/scalardb-cluster-standalone-mode directory.
To start IBM Db2, run the following command:
docker compose up -d db2
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for Db2 in the scalardb-cluster-node.properties file so that the configuration looks as follows:
# For Db2
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:db2://db2-1:50000/sample
scalar.db.username=db2inst1
scalar.db.password=db2inst1
Run MariaDB locally
You can run MariaDB in Docker Compose by using the docker-compose.yml file in the scalardb-samples/scalardb-cluster-standalone-mode directory.
To start MariaDB, run the following command:
docker compose up -d mariadb
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for MariaDB in the scalardb-cluster-node.properties file so that the configuration looks as follows:
# For MariaDB
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:mariadb://mariadb-1:3306
scalar.db.username=root
scalar.db.password=mariadb
Run MySQL locally
You can run MySQL in Docker Compose by using the docker-compose.yml file in the scalardb-samples/scalardb-cluster-standalone-mode directory.
To start MySQL, run the following command:
docker compose up -d mysql
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for MySQL in the scalardb-cluster-node.properties file so that the configuration looks as follows:
# For MySQL
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:mysql://mysql-1:3306/
scalar.db.username=root
scalar.db.password=mysql
Run Oracle Database locally
You can run Oracle Database in Docker Compose by using the docker-compose.yml file in the scalardb-samples/scalardb-cluster-standalone-mode directory.
To start Oracle Database, run the following command:
docker compose up -d oracle
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for Oracle Database in the scalardb-cluster-node.properties file so that the configuration looks as follows:
# For Oracle
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:oracle:thin:@//oracle-1:1521/FREEPDB1
scalar.db.username=SYSTEM
scalar.db.password=Oracle
Run PostgreSQL locally
You can run PostgreSQL in Docker Compose by using the docker-compose.yml file in the scalardb-samples/scalardb-cluster-standalone-mode directory.
To start PostgreSQL, run the following command:
docker compose up -d postgres
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for PostgreSQL in the scalardb-cluster-node.properties file so that the configuration looks as follows:
# For PostgreSQL
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:postgresql://postgres-1:5432/
scalar.db.username=postgres
scalar.db.password=postgres
Run SQL Server locally
You can run SQL Server in Docker Compose by using the docker-compose.yml file in the scalardb-samples/scalardb-cluster-standalone-mode directory.
To start SQL Server, run the following command:
docker compose up -d sqlserver
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for SQL Server in the scalardb-cluster-node.properties file so that the configuration looks as follows:
# For SQL Server
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:sqlserver://sqlserver-1:1433;encrypt=true;trustServerCertificate=true
scalar.db.username=sa
scalar.db.password=SqlServer22
Select your NewSQL database.
- AlloyDB
- Spanner
- TiDB
- YugabyteDB
Run AlloyDB locally
You can run AlloyDB Omni in Docker Compose by using the docker-compose.yml file in the scalardb-samples/scalardb-cluster-standalone-mode directory.
To start AlloyDB Omni, run the following command:
docker compose up -d alloydb
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for AlloyDB in the scalardb-cluster-node.properties file so that the configuration looks as follows:
# For AlloyDB
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:postgresql://alloydb-1:5432/
scalar.db.username=postgres
scalar.db.password=postgres
Run Spanner locally
You can run Spanner Omni in Docker Compose by using the docker-compose.yml file in the scalardb-samples/scalardb-cluster-standalone-mode directory.
To start Spanner Omni, run the following command:
docker compose up -d spanner spanner-init
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for Spanner in the scalardb-cluster-node.properties file so that the configuration looks as follows:
# For Spanner
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:cloudspanner://spanner-1:15000/databases/test-db;isExperimentalHost=true;usePlainText=true
scalar.db.username=
scalar.db.password=
Run TiDB locally
You can run TiDB locally by using the TiUP tool. For installation instructions, see Install TiUP.
To start TiDB, run the following command:
tiup playground v8.5 --without-monitor
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for TiDB in the scalardb-cluster-node.properties file so that the configuration looks as follows:
# For TiDB
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:mysql://host.docker.internal:4000/
scalar.db.username=root
scalar.db.password=
Run YugabyteDB locally
You can run YugabyteDB in Docker Compose by using the docker-compose.yml file in the scalardb-samples/scalardb-cluster-standalone-mode directory.
To start YugabyteDB, run the following command:
docker compose up -d yugabyte
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for YugabyteDB in the scalardb-cluster-node.properties file so that the configuration looks as follows:
# For Yugabyte
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:yugabytedb://yugabyte-1:5433/postgres
scalar.db.username=yugabyte
scalar.db.password=yugabyte
Select your NoSQL database.
- Cassandra
- Cosmos DB for NoSQL
- DynamoDB
Run Cassandra locally
You can run Apache Cassandra in Docker Compose by using the docker-compose.yml file in the scalardb-samples/scalardb-cluster-standalone-mode directory.
To start Apache Cassandra, run the following command:
docker compose up -d cassandra
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for Cassandra in the scalardb-cluster-node.properties file so that the configuration looks as follows:
# For Cassandra
scalar.db.storage=cassandra
scalar.db.contact_points=cassandra-1
scalar.db.username=cassandra
scalar.db.password=cassandra
To use Azure Cosmos DB for NoSQL, you must have an Azure account. If you don't have an Azure account, visit Create an Azure Cosmos DB account.
Configure Cosmos DB for NoSQL
Set the default consistency level to Strong according to the official document at Configure the default consistency level.
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Be sure to change the values for scalar.db.contact_points and scalar.db.password as described.
# For Cosmos DB
scalar.db.storage=cosmos
scalar.db.contact_points=<COSMOS_DB_FOR_NOSQL_URI>
scalar.db.password=<COSMOS_DB_FOR_NOSQL_KEY>
You can use the primary key or the secondary key in your Azure Cosmos DB account as the value for scalar.db.password.
Run Amazon DynamoDB Local
You can run Amazon DynamoDB Local in Docker Compose by using the docker-compose.yml file in the scalardb-samples/scalardb-cluster-standalone-mode directory.
To start Amazon DynamoDB Local, run the following command:
docker compose up -d dynamodb
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for Amazon DynamoDB Local in the scalardb-cluster-node.properties file so that the configuration looks as follows:
# For DynamoDB Local
scalar.db.storage=dynamo
scalar.db.contact_points=sample
scalar.db.username=sample
scalar.db.password=sample
scalar.db.dynamo.endpoint_override=http://dynamodb-1:8000
- Blob Storage
- Cloud Storage
- S3
Run Azurite
You can run Azurite, which is a local emulator for Blob Storage, in Docker Compose by using thedocker-compose.yml file in the scalardb-samples/scalardb-cluster-standalone-mode directory. To start Blob Storage, run the following command:docker compose up -d blobstorage
test-container by running the following command:docker compose up blobstorage-container-creator
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in thescalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Please uncomment the properties for Blob Storage in the scalardb-cluster-node.properties file so that the configuration looks as follows:# For Blob Storage
scalar.db.storage=blob-storage
scalar.db.contact_points=http://blobstorage-1:10000/test/test-container
scalar.db.username=test
scalar.db.password=test
To use Google Cloud Storage, you must have a Google Cloud account. If you don't have a Google Cloud account, visit Get started with Google Cloud.
Configure Cloud Storage
Create a Cloud Storage bucket. For instructions on creating a bucket, see Create buckets. You also need a service account key for authentication. For details, see Create a service account key.
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Be sure to change the values for scalar.db.contact_points, scalar.db.username, and scalar.db.password as described.
# For Cloud Storage
scalar.db.storage=cloud-storage
scalar.db.contact_points=<CLOUD_STORAGE_BUCKET_NAME>
scalar.db.username=<GCP_PROJECT_ID>
scalar.db.password=<GCP_SERVICE_ACCOUNT_KEY_JSON>
scalar.db.password to the full content of your Google Cloud service account key file as a single-line JSON.To use Amazon S3, you must have an AWS account. If you don't have an AWS account, visit Create an AWS account.
Configure Amazon S3
Create an S3 bucket. For instructions on creating a bucket, see Creating a bucket. You also need an access key for authentication. For details, see Creating access keys.
Configure ScalarDB Cluster
The scalardb-cluster-node.properties file in the scalardb-samples/scalardb-cluster-standalone-mode directory contains database configurations. Be sure to change the values for scalar.db.contact_points, scalar.db.username, and scalar.db.password as described.
# For S3
scalar.db.storage=s3
scalar.db.contact_points=<REGION>/<S3_BUCKET_NAME>
scalar.db.username=<AWS_ACCESS_KEY>
scalar.db.password=<AWS_SECRET_ACCESS_KEY>
scalar.db.contact_points is <REGION>/<S3_BUCKET_NAME> (for example, us-east-1/my-bucket).For a comprehensive list of configurations for ScalarDB, see ScalarDB Configurations.
Set up ScalarDB Cluster in standalone mode​
To set up ScalarDB Cluster in standalone mode, you'll need to configure ScalarDB Cluster to run non-transactional storage operations, set a license key, and then start ScalarDB Cluster.
Configure ScalarDB Cluster to run non-transactional storage operations​
To run non-transactional storage operations, you need to configure the scalar.db.transaction_manager property to single-crud-operation in the configuration file scalardb-cluster-node.properties:
scalar.db.transaction_manager=single-crud-operation
Set the license key​
Set the license key (trial license or commercial license) for the ScalarDB Clusters in the properties file. For details, see How to Configure a Product License Key.
Start ScalarDB Cluster in standalone mode​
To start ScalarDB Cluster in standalone mode, run the following command:
If you want to change other configurations for ScalarDB Cluster, update the scalardb-cluster-node.properties file before running the command below.
docker compose up -d scalardb-cluster-node
Create or import a schema​
ScalarDB has its own data model and schema that maps to the implementation-specific data model and schema.
- Need to create a database schema? See SQL CLI.
- Need to import an existing database? See Importing Existing Tables to ScalarDB by Using ScalarDB Schema Loader.
Also, for a list of supported DDLs, see ScalarDB SQL Grammar.
Load initial data as necessary​
ScalarDB Cluster Data Loader is a utility for importing and exporting data with ScalarDB Cluster.
- Need to import data into your database? See Importing data.
- Need to export data from your database? See Exporting data.
Create your application​
- JDBC
- Java
Configure your JDBC application
This section describes how to add the ScalarDB JDBC driver to your project and how to configure it to run non-transactional storage operations by using Java.
Add the ScalarDB JDBC driver to your project
You can add the ScalarDB JDBC driver as a build dependency to your application by using Gradle or Maven.
Select your build tool, and follow the instructions to add the build dependency for the ScalarDB JDBC driver to your application.
- Gradle
- Maven
To add the build dependency for the ScalarDB JDBC driver by using Gradle, add the following to build.gradle in your application:
dependencies {
implementation 'com.scalar-labs:scalardb-sql-jdbc:3.18.0'
implementation 'com.scalar-labs:scalardb-cluster-java-client-sdk:3.18.0'
}
To add the build dependency for the ScalarDB SQL API by using Maven, add the following to pom.xml in your application:
<dependencies>
<dependency>
<groupId>com.scalar-labs</groupId>
<artifactId>scalardb-sql-jdbc</artifactId>
<version>3.18.0</version>
</dependency>
<dependency>
<groupId>com.scalar-labs</groupId>
<artifactId>scalardb-cluster-java-client-sdk</artifactId>
<version>3.18.0</version>
</dependency>
</dependencies>
Configure the ScalarDB Cluster Java SDK for the SQL interface
For details about configuring the ScalarDB Cluster Java SDK for the SQL interface, see ScalarDB Cluster SQL client configurations.
Use the JDBC API
For details about the JDBC API, see ScalarDB JDBC Guide.
The following limitations apply to non-transactional storage operations:
- Beginning a transaction is not supported.
- Executing multiple mutations in a single SQL statement is not supported.
- The isolation level is always
READ_COMMITTED.
Learn more
Configure your Java application
This section describes how to add the ScalarDB SQL API to your project and how to configure it to run non-transactional storage operations by using Java.
Add ScalarDB SQL API to your project
You can add the ScalarDB SQL API as a build dependency to your application by using Gradle or Maven.
Select your build tool, and follow the instructions to add the build dependency for the ScalarDB SQL API to your application.
- Gradle
- Maven
To add the build dependency for the ScalarDB SQL API by using Gradle, add the following to build.gradle in your application:
dependencies {
implementation 'com.scalar-labs:scalardb-sql:3.18.0'
implementation 'com.scalar-labs:scalardb-cluster-java-client-sdk:3.18.0'
}
To add the build dependency for the ScalarDB SQL API by using Maven, add the following to pom.xml in your application:
<dependencies>
<dependency>
<groupId>com.scalar-labs</groupId>
<artifactId>scalardb-sql</artifactId>
<version>3.18.0</version>
</dependency>
<dependency>
<groupId>com.scalar-labs</groupId>
<artifactId>scalardb-cluster-java-client-sdk</artifactId>
<version>3.18.0</version>
</dependency>
</dependencies>
Configure the ScalarDB Cluster Java SDK for the SQL interface
For details about configuring the ScalarDB Cluster Java SDK for the SQL interface, see ScalarDB Cluster SQL client configurations.
Use the Java API
For details about the SQL API, see ScalarDB SQL API Guide.
The following limitations apply to non-transactional storage operations:
- Beginning a transaction is not supported.
- Executing multiple mutations in a single SQL statement is not supported.
- The isolation level is always
READ_COMMITTED.