{"id":23282771,"url":"https://github.com/itsallcode/simple-jdbc","last_synced_at":"2026-02-09T18:03:38.617Z","repository":{"id":40442600,"uuid":"448284295","full_name":"itsallcode/simple-jdbc","owner":"itsallcode","description":"Wrapper to simplify working with JDBC","archived":false,"fork":false,"pushed_at":"2025-01-14T19:16:45.000Z","size":496,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T20:37:56.620Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/itsallcode.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-15T13:25:40.000Z","updated_at":"2025-01-08T08:13:09.000Z","dependencies_parsed_at":"2023-10-10T22:13:59.200Z","dependency_job_id":"795926ff-4c8e-4edc-9be0-852ac3b4c111","html_url":"https://github.com/itsallcode/simple-jdbc","commit_stats":{"total_commits":94,"total_committers":3,"mean_commits":"31.333333333333332","dds":"0.12765957446808507","last_synced_commit":"c0000c44e775d37da73c88f3c8aa874ea77d2d32"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsallcode%2Fsimple-jdbc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsallcode%2Fsimple-jdbc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsallcode%2Fsimple-jdbc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsallcode%2Fsimple-jdbc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itsallcode","download_url":"https://codeload.github.com/itsallcode/simple-jdbc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238545164,"owners_count":19490034,"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":[],"created_at":"2024-12-20T00:29:36.260Z","updated_at":"2025-10-27T18:31:58.558Z","avatar_url":"https://github.com/itsallcode.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-jdbc\n\nWrapper to simplify working with JDBC.\n\n**This project is at an early development stage and the API will change without backwards compatibility.**\n\n[![Java CI](https://github.com/itsallcode/simple-jdbc/actions/workflows/build.yml/badge.svg)](https://github.com/itsallcode/simple-jdbc/actions/workflows/build.yml)\n[![CodeQL](https://github.com/itsallcode/simple-jdbc/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/itsallcode/simple-jdbc/actions/workflows/codeql-analysis.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Asimple-jdbc\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Asimple-jdbc)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Asimple-jdbc\u0026metric=coverage)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Asimple-jdbc)\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Asimple-jdbc\u0026metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Asimple-jdbc)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Asimple-jdbc\u0026metric=security_rating)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Asimple-jdbc)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Asimple-jdbc\u0026metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Asimple-jdbc)\n[![Maven Central](https://img.shields.io/maven-central/v/org.itsallcode/simple-jdbc)](https://search.maven.org/artifact/org.itsallcode/simple-jdbc)\n\n* [Changelog](CHANGELOG.md)\n* [API JavaDoc](https://blog.itsallcode.org/simple-jdbc/javadoc/org.itsallcode.jdbc/module-summary.html)\n* [Test report](https://blog.itsallcode.org/simple-jdbc/reports/tests/test/index.html)\n* [Coverage report](https://blog.itsallcode.org/simple-jdbc/reports/jacoco/test/html/index.html)\n\n## Usage\n\nThis project requires Java 17 or later.\n\n### Add Dependency\n\nAdd dependency to your Gradle project:\n\n```groovy\ndependencies {\n    implementation 'org.itsallcode:simple-jdbc:0.10.0'\n}\n```\n\nAdd dependency to your Maven project:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.itsallcode\u003c/groupId\u003e\n  \u003cartifactId\u003esimple-jdbc\u003c/artifactId\u003e\n  \u003cversion\u003e0.10.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Features\n\nSee features and API documentation in the [API documentation](https://blog.itsallcode.org/simple-jdbc/javadoc/org.itsallcode.jdbc/module-summary.html).\n\n### Examples\n\nSee complete example code in [ExampleTest](src/test/java/org/itsallcode/jdbc/example/ExampleTest.java).\n\n#### Imports\n\n```java\nimport org.itsallcode.jdbc.ConnectionFactory;\nimport org.itsallcode.jdbc.SimpleConnection;\nimport org.itsallcode.jdbc.Transaction;\nimport org.itsallcode.jdbc.resultset.batch.StatementBatch;\nimport org.itsallcode.jdbc.resultset.SimpleResultSet;\nimport org.itsallcode.jdbc.resultset.generic.Row;\n```\n\n#### Create `SimpleConnection`\n\n```java\nfinal ConnectionFactory connectionFactory = ConnectionFactory.create(Context.builder().build());\ntry (SimpleConnection connection = connectionFactory.create(\"jdbc:h2:mem:\", \"user\", \"password\")) {\n    // Use connection...\n}\n```\n\n#### Batch Insert Using Rows\n\n```java\n// Define a model record or class\nrecord Name(int id, String name) {\n    static void setPreparedStatement(final Name row, final PreparedStatement stmt) throws SQLException {\n        stmt.setInt(1, row.id);\n        stmt.setString(2, row.name);\n    }\n}\n\nconnection.batchInsert(Name.class)\n        .into(\"NAMES\", List.of(\"ID\", \"NAME\"))\n        .rows(Stream.of(new Name(1, \"a\"), new Name(2, \"b\"), new Name(3, \"c\")))\n        .mapping(Name::setPreparedStatement)\n        .start();\n```\n\n#### Direct Batch Insert\n\nThis allows using batch inserts without creating objects for each row to avoid memory allocations.\n\n```java\ntry (PreparedStatementBatch batch = transaction.preparedStatementBatch().into(\"NAMES\", List.of(\"ID\", \"NAME\")).build()) {\n    for (int i = 0; i \u003c 5; i++) {\n        final int id = i + 1;\n        batch.add(ps -\u003e {\n            ps.setInt(1, id);\n            ps.setString(2, \"name\" + id);\n        });\n    }\n}\n```\n\n#### Transactions\n\n`Transaction` implements `DbOperations` which provides most of the methods as `SimpleConnection`. Transactions will be automatically rolled back during close unless you commit before.\n\n```java\ntry (Transaction transaction = connection.startTransaction()) {\n    // Use transaction\n    // ...\n    // Commit successful transaction\n    transaction.commit();\n}\n```\n\n#### Query Using Generic Row Type\n\n```java\ntry (SimpleResultSet\u003cRow\u003e rs = connection.query(\"select * from names order by id\")) {\n    final List\u003cRow\u003e result = rs.stream().toList();\n    assertEquals(3, result.size());\n    assertEquals(1, result.get(0).get(0).value());\n}\n```\n\n#### Query Using Row Mapper and Prepared Statement\n\n```java\ntry (SimpleResultSet\u003cName\u003e result = connection.query(\"select id, name from names where id = ?\",\n        ps -\u003e ps.setInt(1, 2),\n        (rs, idx) -\u003e new Name(rs.getInt(\"id\"), rs.getString(\"name\")))) {\n    final List\u003cName\u003e names = result.stream().toList();\n    assertEquals(1, names.size());\n    assertEquals(new Name(2, \"b\"), names.get(0));\n}\n```\n\n## Development\n\n### Check if dependencies are up-to-date\n\n```sh\n./gradlew dependencyUpdates\n```\n\n### Building\n\nInstall to local maven repository:\n\n```sh\n./gradlew publishToMavenLocal\n```\n\n### Test Coverage\n\nTo calculate and view test coverage:\n\n```sh\n./gradlew check jacocoTestReport\nopen build/reports/jacoco/test/html/index.html\n```\n\n### View Generated Javadoc\n\n```sh\n./gradlew javadoc\nopen build/docs/javadoc/index.html\n```\n\n### Publish to Maven Central\n\n#### Preparations\n\n1. Checkout the `main` branch, create a new branch.\n2. Update version number in `build.gradle` and `README.md`.\n3. Add changes in new version to `CHANGELOG.md`.\n4. Commit and push changes.\n5. Create a new pull request, have it reviewed and merged to `main`.\n\n#### Perform the Release\n\n1. Start the release workflow\n  * Run command `gh workflow run release.yml --repo itsallcode/simple-jdbc --ref main`\n  * or go to [GitHub Actions](https://github.com/itsallcode/simple-jdbc/actions/workflows/release.yml) and start the `release.yml` workflow on branch `main`.\n2. Update title and description of the newly created [GitHub release](https://github.com/itsallcode/simple-jdbc/releases).\n3. After some time the release will be available at [Maven Central](https://repo1.maven.org/maven2/org/itsallcode/simple-jdbc/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsallcode%2Fsimple-jdbc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitsallcode%2Fsimple-jdbc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsallcode%2Fsimple-jdbc/lists"}