{"id":15524128,"url":"https://github.com/taketoday/today-jdbc","last_synced_at":"2025-04-23T07:29:40.722Z","repository":{"id":56456279,"uuid":"203178524","full_name":"TAKETODAY/today-jdbc","owner":"TAKETODAY","description":"😜 TODAY Jdbc","archived":false,"fork":false,"pushed_at":"2021-08-16T15:08:52.000Z","size":822,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-29T22:41:18.599Z","etag":null,"topics":["high-performance","java","jdbc","lightweight","orm","orm-framework"],"latest_commit_sha":null,"homepage":"https://taketoday.cn","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TAKETODAY.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-19T13:28:54.000Z","updated_at":"2023-09-01T11:45:12.000Z","dependencies_parsed_at":"2022-08-15T19:10:15.076Z","dependency_job_id":null,"html_url":"https://github.com/TAKETODAY/today-jdbc","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TAKETODAY%2Ftoday-jdbc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TAKETODAY%2Ftoday-jdbc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TAKETODAY%2Ftoday-jdbc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TAKETODAY%2Ftoday-jdbc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TAKETODAY","download_url":"https://codeload.github.com/TAKETODAY/today-jdbc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250390460,"owners_count":21422708,"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":["high-performance","java","jdbc","lightweight","orm","orm-framework"],"created_at":"2024-10-02T10:49:15.293Z","updated_at":"2025-04-23T07:29:40.664Z","avatar_url":"https://github.com/TAKETODAY.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TODAY JDBC \n\n[Sql2o](https://github.com/aaberg/sql2o) 改良版\n\n\n![Java8](https://img.shields.io/badge/JDK-8+-success.svg)\n[![GPLv3](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE)\n[![Author](https://img.shields.io/badge/Author-TODAY-blue.svg)](https://github.com/TAKETODAY)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/b5b336564b304eaba40a39a211c2dd45)](https://www.codacy.com/gh/TAKETODAY/today-jdbc/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=TAKETODAY/today-jdbc\u0026amp;utm_campaign=Badge_Grade)\n[![GitHub CI](https://github.com/TAKETODAY/today-jdbc/workflows/GitHub%20CI/badge.svg)](https://github.com/TAKETODAY/today-jdbc/actions)\n\n## 🛠️ 安装\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecn.taketoday\u003c/groupId\u003e\n  \u003cartifactId\u003etoday-jdbc\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.0.RELEASE\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n#### 使用实例\n\n```java\n  @Test\n  public void testFetch() {\n    createAndFillUserTable();\n\n    try (JdbcConnection con = jdbcOperations.open()) {\n\n      Date before = new Date();\n      List\u003cUser\u003e allUsers = con.createQuery(\"select * from User\").fetch(User.class);\n\n      assertNotNull(allUsers);\n\n      Date after = new Date();\n      long span = after.getTime() - before.getTime();\n      System.out.println(String.format(\"Fetched %s user: %s ms\", insertIntoUsers, span));\n\n      // repeat this\n      before = new Date();\n      allUsers = con.createQuery(\"select * from User\").fetch(User.class);\n      after = new Date();\n      span = after.getTime() - before.getTime();\n      System.out.println(String.format(\"Again Fetched %s user: %s ms\", insertIntoUsers, span));\n\n      assertEquals(allUsers.size(), insertIntoUsers);\n    }\n    deleteUserTable();\n  }\n  \n  @Test\n  public void testBatch() {\n    jdbcOperations.createQuery(\n            \"create table User(\\n\" +\n            \"id int identity primary key,\\n\" +\n            \"name varchar(20),\\n\" +\n            \"email varchar(255),\\n\" +\n            \"text varchar(100))\").executeUpdate();\n\n    String insQuery = \"insert into User(name, email, text) values (:name, :email, :text)\";\n\n    JdbcConnection con = jdbcOperations.beginTransaction();\n    int[] inserted = con.createQuery(insQuery)\n            .addParameter(\"name\", \"test\")\n            .addParameter(\"email\", \"test@test.com\")\n            .addParameter(\"text\", \"something exciting\")\n            .addToBatch()\n\n            .addParameter(\"name\", \"test2\")\n            .addParameter(\"email\", \"test2@test.com\")\n            .addParameter(\"text\", \"something exciting too\")\n            .addToBatch()\n\n            .addParameter(\"name\", \"test3\")\n            .addParameter(\"email\", \"test3@test.com\")\n            .addParameter(\"text\", \"blablabla\")\n            .addToBatch()\n\n            .executeBatch()\n            .getBatchResult();\n    con.commit();\n\n    assertEquals(3, inserted.length);\n    for (int i : inserted) {\n      assertEquals(1, i);\n    }\n\n    deleteUserTable();\n  }\n  \n```\n\n\n#### Performance of SELECT\n\nExecute 5000 SELECT statements against a DB and map the data returned to a POJO.\nCode is available [here](/src/test/java/cn/taketoday/jdbc/performance/PojoPerformanceTest.java).\n\nMethod                                                              | Duration               |\n------------------------------------------------------------------- | ---------------------- |\nHand coded \u003ccode\u003eResultSet\u003c/code\u003e                                   | 49ms                   |\nTODAY JDBC                                                          | 59ms (20.41% slower)   |\n[Sql2o](https://github.com/aaberg/sql2o)                            | 65ms (32.65% slower)   |\n[Apache DbUtils](http://commons.apache.org/proper/commons-dbutils/) | 107ms (118.37% slower) |\n[MyBatis](http://mybatis.github.io/mybatis-3/)                      | 245ms (400.00% slower) |\n[JDBI](http://jdbi.org/)                                            | 273ms (457.14% slower) |\n[Hibernate](http://hibernate.org/)                                  | 280ms (471.43% slower) |\n[Spring JdbcTemplate](http://docs.spring.io/spring/docs/current/spring-framework-reference/html/jdbc.html) | 342ms (597.96% slower) |\n[jOOQ](http://www.jooq.org)                                         | 374ms (663.27% slower) |\n\n\n## 🙏 鸣谢\n本项目的诞生离不开以下开源项目：\n* [TODAY Context](https://github.com/TAKETODAY/today-context): A Java library for dependency injection and aspect oriented programing\n* [Sql2o](https://github.com/aaberg/sql2o): sql2o is a small library, which makes it easy to convert the result of your sql-statements into objects. No resultset hacking required. Kind of like an orm, but without the sql-generation capabilities. Supports named parameters.\n\n## 📄 开源协议\n请查看 [GNU GENERAL PUBLIC LICENSE](https://github.com/TAKETODAY/today-jdbc/blob/master/LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaketoday%2Ftoday-jdbc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaketoday%2Ftoday-jdbc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaketoday%2Ftoday-jdbc/lists"}