Getting Started with ScalarDB
This getting started tutorial explains how to configure your preferred database in ScalarDB and illustrates the process of creating a sample e-commerce application, where items can be ordered and paid for with a credit card by using ScalarDB. The sample e-commerce application shows how users can order and pay for items by using a line of credit.
Since the focus of the sample application is to demonstrate using ScalarDB, application-specific error handling, authentication processing, and similar functions are not included in the sample application. For details about exception handling in ScalarDB, see How to handle exceptions.
Prerequisites for this sample application
- OpenJDK LTS version (8, 11, 17, or 21) from Eclipse Temurin
- Docker 20.10 or later with Docker Compose V2 or later
This sample application has been tested with OpenJDK from Eclipse Temurin. ScalarDB itself, however, has been tested with JDK distributions from various vendors. For details about the requirements for ScalarDB, including compatible JDK distributions, please see Requirements.
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 sample application by running the following command:
cd scalardb-samples/scalardb-sample
Set up your database for ScalarDB
Select your database, and follow the instructions to configure it for ScalarDB.
For a list of databases that ScalarDB supports, see Databases.
- MySQL
- PostgreSQL
- Oracle Database
- SQL Server
- DynamoDB
- Cosmos DB for NoSQL
- Cassandra
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
Run PostgreSQL locally
You can run PostgreSQL in Docker Compose by using the docker-compose.yml
file in the scalardb-samples/scalardb-sample
directory.
To start PostgreSQL, run the following command:
docker compose up -d postgres
Configure ScalarDB
The database.properties file in the scalardb-samples/scalardb-sample
directory contains database configurations for ScalarDB. Please uncomment the properties for PostgreSQL in the database.properties file so that the configuration looks as follows:
# For PostgreSQL
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:postgresql://localhost:5432/
scalar.db.username=postgres
scalar.db.password=postgres
Run Oracle Database locally
You can run Oracle Database in Docker Compose by using the docker-compose.yml
file in the scalardb-samples/scalardb-sample
directory.
To start Oracle Database, run the following command:
docker compose up -d oracle
Configure ScalarDB
The database.properties file in the scalardb-samples/scalardb-sample
directory contains database configurations for ScalarDB. Please uncomment the properties for Oracle Database in the database.properties file so that the configuration looks as follows:
# For Oracle
scalar.db.storage=jdbc
scalar.db.contact_points=jdbc:oracle:thin:@//localhost:1521/FREEPDB1
scalar.db.username=SYSTEM
scalar.db.password=Oracle