The application connects to your YugabyteDB instance via
topology-aware JDBC driver and performs basic SQL
operations. The instructions below are provided for YugabyteDB Managed deployments.
If you use a different type of deployment, then update the /src/main/resources/app.properties file with proper connection parameters.
- Java Development Kit, version 8 or later
- Maven 3.0 or later
- Command line tool or your favourite IDE, such as IntelliJ IDEA, or Eclipse.
- Start YugabyteDB Managed instance. Free tier exists.
- Add an IP address of your machine/laptop to the IP allow list
- Build the app with Maven:
mvn clean package
- Run the app:
java -cp target/yugabyte-simple-java-app-1.0-SNAPSHOT.jar SampleApp
Upon successful execution, you will see output similar to the following:
>>>> Successfully connected to YugabyteDB!
>>>> Successfully created DemoAccount table.
>>>> Selecting accounts:
name = Jessica, age = 28, country = USA, balance = 10000
name = John, age = 28, country = Canada, balance = 9000
>>>> Transferred 800 between accounts.
>>>> Selecting accounts:
name = Jessica, age = 28, country = USA, balance = 9200
name = John, age = 28, country = Canada, balance = 9800