Create a Sample Application That Uses ScalarDB
This tutorial describes how to create a sample e-commerce application by using ScalarDB.
Overview
The sample e-commerce application shows how users can order and pay for items by using a line of credit.
The database that you will be using in the sample application is Cassandra. Although Cassandra does not provide ACID transaction capabilities, you can make transactions ACID compliant by having your application connect to the database through ScalarDB.
To reference the sample application source code, see src/main/java/sample/Sample.java.
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 Handle exceptions.
What you can do in this sample application
The sample application supports the following types of transactions:
- Get customer information.
- Place an order by using a line of credit.
- Checks if the cost of the order is below the customer's credit limit.
- If the check passes, records the order history and updates the amount the customer has spent.
- Get order information by order ID.
- Get order information by customer ID.
- Make a payment.
- Reduces the amount the customer has spent.
Prerequisites
- One of the following Java Development Kits (JDKs):
- Oracle JDK LTS version (8, 11, or 17)
- OpenJDK LTS version (8, 11, or 17)
- Docker 20.10 or later with Docker Compose V2 or later
We recommend using the LTS versions mentioned above, but other non-LTS versions may work.
In addition, other JDKs should work with ScalarDB, but we haven't tested them.