{"id":19989050,"url":"https://github.com/icemap/tidb-example-java-jdbc","last_synced_at":"2026-06-08T06:35:26.983Z","repository":{"id":119433203,"uuid":"468826070","full_name":"Icemap/tidb-example-java-jdbc","owner":"Icemap","description":"An example of using Java JDBC as a connector to connect to TiDB","archived":false,"fork":false,"pushed_at":"2022-03-12T10:42:55.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T21:42:54.675Z","etag":null,"topics":["java","jdbc","tidb"],"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/Icemap.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-03-11T16:37:15.000Z","updated_at":"2022-03-13T13:28:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"52b4ece7-a344-4cd0-a943-72e454657f47","html_url":"https://github.com/Icemap/tidb-example-java-jdbc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Icemap/tidb-example-java-jdbc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icemap%2Ftidb-example-java-jdbc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icemap%2Ftidb-example-java-jdbc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icemap%2Ftidb-example-java-jdbc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icemap%2Ftidb-example-java-jdbc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Icemap","download_url":"https://codeload.github.com/Icemap/tidb-example-java-jdbc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icemap%2Ftidb-example-java-jdbc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34051770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["java","jdbc","tidb"],"created_at":"2024-11-13T04:45:17.963Z","updated_at":"2026-06-08T06:35:26.969Z","avatar_url":"https://github.com/Icemap.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TiDB Example - Java JDBC\n\n## Initial database and table\n\nUse [dbinit.sql](src/main/resources/dbinit.sql) to create `bank` database and `accounts` table.\n\n```sql\nSET sql_safe_updates = FALSE;\n\nUSE mysql;\nDROP DATABASE IF EXISTS bank;\nCREATE DATABASE IF NOT EXISTS bank;\n\nUSE bank;\n\nCREATE TABLE accounts (\n    `id` VARCHAR(36),\n    `balance` INTEGER,\n\tPRIMARY KEY (`id`)\n);\n```\n\n## Install maven\n\nIf you have configured `Maven`, skip this part.\n\nTo install Maven on macOS, run the following command:\n\n```brew install maven```\n\nTo install Maven on a Debian-based Linux distribution like Ubuntu:\n\n```apt-get install maven```\n\nTo install Maven on a Red Hat-based Linux distribution like Fedora:\n\n```dnf install maven```\n\nFor other ways to install Maven, see its official [documentation](https://maven.apache.org/install.html).\n\n## Build \n\nNote: It will taken sooooo long when you first time run it, must be more patience.\n\n```mvn clean package```\n\n## Run\n\nRun the jar with dependencies:\n\n```java -jar target/tidb-example-java-jdbc-0.0.1-jar-with-dependencies.jar```\n\nAnd then, you will see the result of example:\n\n```shell\ncheese@CheesedeMacBook-Pro tidb-example-java-jdbc % java -jar target/tidb-example-java-jdbc-0.0.1-jar-with-dependencies.jar\n\n[updateAccounts]:\n    'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO accounts (id, balance) VALUES ('4eda0277-1da1-47eb-86fe-530b61fe6f00', 250)'\n\n[updateAccounts]:\n    'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO accounts (id, balance) VALUES ('76995b64-bf94-4d1c-b06f-3184820e50a2', 1000)'\nExampleDataDAO.updateAccounts:\n    =\u003e 2 total updated accounts\nmain:\n    =\u003e Account balances at time '18:21:16.519458':\n    ID 1 =\u003e $1000\n    ID 2 =\u003e $250\n\n[transferFunds]:\n    'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO accounts (id, balance) VALUES ('76995b64-bf94-4d1c-b06f-3184820e50a2', (( SELECT balance FROM accounts WHERE id = '76995b64-bf94-4d1c-b06f-3184820e50a2' ) - 100 )), ('4eda0277-1da1-47eb-86fe-530b61fe6f00', (( SELECT balance FROM accounts WHERE id = '4eda0277-1da1-47eb-86fe-530b61fe6f00' ) + 100 )) ON DUPLICATE KEY UPDATE balance = VALUES(balance)'\nExampleDataDAO.transferFunds:\n    =\u003e $100 transferred between accounts 76995b64-bf94-4d1c-b06f-3184820e50a2 and 4eda0277-1da1-47eb-86fe-530b61fe6f00, 4 rows updated\nmain:\n    =\u003e Account balances at time '18:21:16.571599':\n    ID 1 =\u003e $900\n    ID 2 =\u003e $350\n\nExampleDataDAO.bulkInsertRandomAccountData:\n    'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO accounts (id, balance) VALUES ('aa1a5526-9413-4e6f-bc2c-61e1c707ee55', 832767234)'\n    =\u003e 100 row(s) updated in this batch\n\nExampleDataDAO.bulkInsertRandomAccountData:\n    'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO accounts (id, balance) VALUES ('bee22fe2-befb-4dc1-8504-acdf746dc5ea', 18439597)'\n    =\u003e 100 row(s) updated in this batch\n\nExampleDataDAO.bulkInsertRandomAccountData:\n    'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO accounts (id, balance) VALUES ('84ce1dd1-eefa-482e-bd93-802a0b02dbb0', 340197694)'\n    =\u003e 100 row(s) updated in this batch\n\nExampleDataDAO.bulkInsertRandomAccountData:\n    'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO accounts (id, balance) VALUES ('5575e17b-99f0-45a1-807e-f9abc00d06cf', 443655887)'\n    =\u003e 100 row(s) updated in this batch\n\nExampleDataDAO.bulkInsertRandomAccountData:\n    'com.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO accounts (id, balance) VALUES ('6a78223a-69e7-4785-ad32-719429a1eb2d', 727708267)'\n    =\u003e 100 row(s) updated in this batch\n\nExampleDataDAO.bulkInsertRandomAccountData:\n    =\u003e finished, 500 total rows inserted\n\n[readAccounts]:\n    'com.mysql.cj.jdbc.ClientPreparedStatement: SELECT id, balance FROM accounts LIMIT 10'\n    id       =\u003e 46d16a7f-addf-4398-98a6-7fb07365fd9e\n    balance  =\u003e        900\n    id       =\u003e 4dab9a27-a595-4ef3-bd8e-999b888ef2a5\n    balance  =\u003e        350\n    id       =\u003e d5993a6f-86d2-490a-8531-2b67b62ee0cf\n    balance  =\u003e  462064494\n    id       =\u003e 13bd7757-f06c-4bfb-a1a7-a15985761197\n    balance  =\u003e  739003150\n    id       =\u003e 650c1b9e-2bb1-4405-9823-f37fafabc61a\n    balance  =\u003e  275945148\n    id       =\u003e 825549e6-d4fd-437d-9930-a87714a0b566\n    balance  =\u003e  851495285\n    id       =\u003e b596fcc2-f142-4bbf-8634-f0446b1e57b1\n    balance  =\u003e  337337199\n    id       =\u003e c9b0adec-4be2-4537-b93b-72df8992d3b1\n    balance  =\u003e  243802065\n    id       =\u003e 5f56eea3-a2e1-47c6-8ba3-ee5ba08ffc65\n    balance  =\u003e  719219129\n    id       =\u003e 91cb1d34-e2d9-4f17-ae3e-33090d459cce\n    balance  =\u003e    7478440\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficemap%2Ftidb-example-java-jdbc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficemap%2Ftidb-example-java-jdbc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficemap%2Ftidb-example-java-jdbc/lists"}