{"id":21042692,"url":"https://github.com/yugabytedb-samples/yugabyte-simple-java-app","last_synced_at":"2025-05-15T17:31:00.258Z","repository":{"id":46243212,"uuid":"450550212","full_name":"YugabyteDB-Samples/yugabyte-simple-java-app","owner":"YugabyteDB-Samples","description":"A simple Java application that connects to a YugabyteDB database cluster and performs basic CRUD operations.","archived":false,"fork":false,"pushed_at":"2024-07-16T15:59:14.000Z","size":208,"stargazers_count":3,"open_issues_count":2,"forks_count":9,"subscribers_count":58,"default_branch":"main","last_synced_at":"2025-04-03T12:11:19.486Z","etag":null,"topics":["cloud-database","cloud-native","demos","distributed-database","java","yugabyte"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YugabyteDB-Samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-21T15:50:39.000Z","updated_at":"2024-07-16T15:59:17.000Z","dependencies_parsed_at":"2024-07-16T19:38:52.470Z","dependency_job_id":null,"html_url":"https://github.com/YugabyteDB-Samples/yugabyte-simple-java-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabyte-simple-java-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabyte-simple-java-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabyte-simple-java-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabyte-simple-java-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YugabyteDB-Samples","download_url":"https://codeload.github.com/YugabyteDB-Samples/yugabyte-simple-java-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254388052,"owners_count":22062976,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud-database","cloud-native","demos","distributed-database","java","yugabyte"],"created_at":"2024-11-19T14:08:41.156Z","updated_at":"2025-05-15T17:30:59.958Z","avatar_url":"https://github.com/YugabyteDB-Samples.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Java Application for YugabyteDB\n\nThe application connects to your YugabyteDB instance via \n[topology-aware JDBC driver](https://docs.yugabyte.com/latest/integrations/jdbc-driver/) and performs basic SQL \noperations. The instructions below are provided for [YugabyteDB Aeon](https://cloud.yugabyte.com/) deployments.\nIf you use a different type of deployment, then update the `/src/main/resources/app.properties` file with proper connection parameters.\n\n## Prerequisite\n* Java Development Kit, version 8 or later\n* Maven 3.0 or later\n* Command line tool or your favourite IDE, such as IntelliJ IDEA, or Eclipse.\n\n## Start YugabyteDB Aeon Cluster\n\n* [Start YugabyteDB Aeon](https://docs.yugabyte.com/latest/yugabyte-cloud/cloud-quickstart/qs-add/) instance. Free tier exists.\n* Add an IP address of your machine/laptop to the [IP allow list](https://docs.yugabyte.com/latest/yugabyte-cloud/cloud-secure-clusters/add-connections/#manage-ip-allow-lists)\n\n## Clone App From GitHub\n\nClone the application to your machine:\n\n```bash\ngit clone https://github.com/YugabyteDB-Samples/yugabyte-simple-java-app.git \u0026\u0026 cd yugabyte-simple-java-app\n```\n\n## Provide Cluster Connection Parameters\n\nThe application needs to establish a secured connection to your YugabyteDB Aeon instance.\n\nOpen the `app.properties` file and specify the following configuration parameters:\n* `host` - the hostname of your cluster instance.\n* `port` - the port number that will be used by the JDBC driver (the default is `5433`)\n* `dbUser` - the database username you used for your instance.\n* `dbPassword` - the database password.\n* `sslMode` - the SSL mode. Set to `verify-full` for YugabyteDB Aeon deployments.\n* `sslRootCert` - a full path to your CA root cert (for example, `/Users/dmagda/certificates/root.crt`) \n\nNote, you can easily find all the settings on the YugabyteDB Aeon dashboard:\n\n![image](src/main/resources/cloud_app_settings.png)\n\n## Build and Run App\n\n1. Build the app with Maven:\n    ```bash\n    mvn clean package\n    ```\n2. Run the app:\n    ```bash\n    java -cp target/yugabyte-simple-java-app-1.0-SNAPSHOT.jar SampleApp\n    ```\n\nUpon successful execution, you will see output similar to the following:\n\n```bash\n\u003e\u003e\u003e\u003e Successfully connected to YugabyteDB!\n\u003e\u003e\u003e\u003e Successfully created DemoAccount table.\n\u003e\u003e\u003e\u003e Selecting accounts:\nname = Jessica, age = 28, country = USA, balance = 10000\nname = John, age = 28, country = Canada, balance = 9000\n\n\u003e\u003e\u003e\u003e Transferred 800 between accounts.\n\u003e\u003e\u003e\u003e Selecting accounts:\nname = Jessica, age = 28, country = USA, balance = 9200\nname = John, age = 28, country = Canada, balance = 9800\n```\n\n## Explore App Logic\n\nCongrats! You successfully executed a simple Java app that works with YugabyteDB.\n\nNow, explore the source code of the `SampleApp.java` file:\n1. `main` method - establishes a connection with your cloud instance via JDBC driver.\n2. `createDatabase` method - creates a table and populates it with sample data.\n3. `selectAccounts` method - queries the data with SQL `SELECT` statements.\n4. `transferMoneyBetweenAccounts` method - updates records consistently with distributed transactions.\n\n## Questions or Issues?\n\nHaving issues running this application or want to learn more from Yugabyte experts?\n\nJoin [our Slack channel](https://communityinviter.com/apps/yugabyte-db/register),\nor raise a question on StackOverflow and tag the question with `yugabytedb`!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugabytedb-samples%2Fyugabyte-simple-java-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyugabytedb-samples%2Fyugabyte-simple-java-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugabytedb-samples%2Fyugabyte-simple-java-app/lists"}