Getting Started with ScalarDB by Using Kotlin
This getting started tutorial explains how to configure your preferred database in ScalarDB and set up a basic electronic money application by using Kotlin. Since Kotlin has Java interoperability, you can use ScalarDB directly from Kotlin.
The electronic money application is simplified for this tutorial and isn't suitable for a production environment.
Prerequisites for this sample application
Because ScalarDB is written in Java, you must have one of the following Java Development Kits (JDKs) installed in your environment:
- Oracle JDK 8
- OpenJDK 8 from Eclipse Temurin, Amazon Corretto, or Microsoft
This sample application only works with Java 8. However, ScalarDB itself works with Java LTS versions, which means that you can use Java LTS versions for your application that uses ScalarDB. For details on the requirements of ScalarDB, such as which Java versions can be used, see Requirements.
In addition, since you'll be using Docker Compose to run the databases, you must have Docker 20.10 or later with Docker Compose V2 or later installed.
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-kotlin-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-kotlin-sample
directory.
To start MySQL, run the following command:
docker compose up -d mysql