-
Create the Table
Once the database is ready go to CQLConsole and create the table
CREATE TABLE IF NOT EXISTS starter_orders (
order_id uuid,
product_id uuid,
product_quantity int,
product_name text,
product_price decimal,
added_to_order_at timestamp,
PRIMARY KEY ((order_id), product_id)
) WITH CLUSTERING ORDER BY (product_id DESC);
- Create an token with role
Databse administrator
git clone https://github.com/clun/astra-sdk-java.git
cd astra-sdk-java
mvn clean install -Dmaven.test.skip=true
Then add the SDK client to the pom.xmlL
<dependency>
<groupId>com.datastax.astra</groupId>
<artifactId>astra-spring-boot-starter</artifactId>
<version>2021.1-SNAPSHOT</version>
</dependency>
- Copy the db id, the cloud region and the apptoken in Application.properties
astra.cloudRegion=us-east-1
astra.databaseId=de9d6c10-c8e6-43f0-95dc-72517cf801ec
astra.applicationToken=AstraCS:lAkKZnycDWcAxCyOiBMdaoie:025dbbb5904xxx
astra.keyspace=bootiful
-
Open this application in an IDE
-
Open
pom.xml
and check reference to the spring boot starter
<dependency>
<groupId>com.datastax.astra</groupId>
<artifactId>astra-spring-boot-starter</artifactId>
<version>2021.1-SNAPSHOT</version>
</dependency>
- Start working with
AstraClientTest
should_list_available_db()
should_create_new_serverless_db()
should_create_cqlSession()
-
Back to the Astra UI create a new KEYSPACE
namespace1
-
Update code to provide namespace name
should_use_documentAPI()
- Run the Application
mvn spring-boot:run