{"id":21939344,"url":"https://github.com/r2dbc/r2dbc-h2","last_synced_at":"2025-04-04T08:09:44.374Z","repository":{"id":33539950,"uuid":"150890379","full_name":"r2dbc/r2dbc-h2","owner":"r2dbc","description":"R2DBC H2 Implementation","archived":false,"fork":false,"pushed_at":"2024-04-23T08:30:29.000Z","size":747,"stargazers_count":205,"open_issues_count":26,"forks_count":46,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-28T07:08:44.400Z","etag":null,"topics":["database","h2","java","reactive","reactive-streams"],"latest_commit_sha":null,"homepage":null,"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/r2dbc.png","metadata":{"files":{"readme":"README.adoc","changelog":"CHANGELOG","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":"2018-09-29T18:06:16.000Z","updated_at":"2025-03-24T09:24:30.000Z","dependencies_parsed_at":"2024-04-23T10:21:00.186Z","dependency_job_id":"fb53b7e9-468e-4757-a6a4-72e306efeeca","html_url":"https://github.com/r2dbc/r2dbc-h2","commit_stats":{"total_commits":227,"total_committers":22,"mean_commits":"10.318181818181818","dds":"0.48017621145374445","last_synced_commit":"4c2805f7883fa342adddda65344389bebd0a35bf"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r2dbc%2Fr2dbc-h2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r2dbc%2Fr2dbc-h2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r2dbc%2Fr2dbc-h2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r2dbc%2Fr2dbc-h2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r2dbc","download_url":"https://codeload.github.com/r2dbc/r2dbc-h2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142074,"owners_count":20890653,"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":["database","h2","java","reactive","reactive-streams"],"created_at":"2024-11-29T02:19:00.231Z","updated_at":"2025-04-04T08:09:44.358Z","avatar_url":"https://github.com/r2dbc.png","language":"Java","readme":"= Reactive Relational Database Connectivity H2 Implementation\n\nimage:https://github.com/r2dbc/r2dbc-h2/workflows/Java%20CI%20with%20Maven/badge.svg?branch=main[\"Java CI with Maven\",link=\"https://github.com/r2dbc/r2dbc-h2/actions?query=workflow%3A%22Java+CI+with+Maven%22+branch%3Amain\"]\n\nimage::https://maven-badges.herokuapp.com/maven-central/io.r2dbc/r2dbc-h2/badge.svg[Maven Central, link=\"https://maven-badges.herokuapp.com/maven-central/io.r2dbc/r2dbc-h2\"]\n\nThis project contains the https://www.h2database.com/html/main.html[H2] implementation of the https://github.com/r2dbc/r2dbc-spi[R2DBC SPI].\nThis implementation is not intended to be used directly, but rather to be used as the backing implementation for a humane client library.\n\nThis driver provides the following features:\n\n* Filesystem or in-memory instances\n* Explict transactions\n* Execution of prepared statements with bindings\n* Execution of batch statements without bindings\n* Read and write support for all data types except LOB types (e.g. `BLOB`, `CLOB`)\n\nWARNING: Since this driver runs on top of the internals of H2, there is risk of change.\n`r2dbc-h2` does not guarantee compatibility except against the version of H2 found in the build file.\nBecause various parts of H2 are blocking, like file and network access, the only non-blocking assurances are in the layers above H2.\nNevertheless, `r2dbc-h2` is a great way to warm up to the usage of R2DBC with a small footprint.\n\n== Code of Conduct\n\nThis project is governed by the https://github.com/r2dbc/.github/blob/main/CODE_OF_CONDUCT.adoc[R2DBC Code of Conduct]. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to mailto:info@r2dbc.io[info@r2dbc.io].\n\n== Getting Started\n\nHere is a quick teaser of how to use R2DBC H2 in Java:\n\n**URL Connection Factory Discovery for In-Memory Databases**\n\n[source,java]\n----\nConnectionFactory connectionFactory = ConnectionFactories.get(\"r2dbc:h2:mem:///testdb\");\n\nPublisher\u003c? extends Connection\u003e connectionPublisher = connectionFactory.create();\n----\n\n**URL Connection Factory Discovery for File Databases**\n\n[source,java]\n----\nConnectionFactory connectionFactory = ConnectionFactories.get(\"r2dbc:h2:file///my/relative/path\");\n\nPublisher\u003c? extends Connection\u003e connectionPublisher = connectionFactory.create();\n----\n\n**Programmatic Connection Factory Discovery**\n\n[source,java]\n----\nConnectionFactoryOptions options = builder()\n    .option(DRIVER, \"h2\")\n    .option(PROTOCOL, \"...\")  // file, mem\n    .option(HOST, \"…\")\n    .option(USER, \"…\")\n    .option(PASSWORD, \"…\")\n    .option(DATABASE, \"…\")\n    .build();\n\nConnectionFactory connectionFactory = ConnectionFactories.get(options);\n\nPublisher\u003c? extends Connection\u003e connectionPublisher = connectionFactory.create();\n\n// Alternative: Creating a Mono using Project Reactor\nMono\u003cConnection\u003e connectionMono = Mono.from(connectionFactory.create());\n----\n\n**Supported ConnectionFactory Discovery Options**\n\n[%header,cols=2*]\n|===\n| Option            | Description\n| `driver`          | Must be `h2`.\n| `protocol`        | Must be `file`, `mem`, or `tcp`. Requires `database` if set _(Optional)_\n| `host`            | Only for `tcp` protocol: Server hostname to connect to. _(Optional)_\n| `port`            | Only for `tcp` protocol: Server port to connect to. _(Optional)_\n| `username`        | Login username.\n| `password`        | Login password.\n| `database`        | Database to use. For `file` protocol: Relative (`r2dbc:h2:file//../relative/file/name`) or absolute (`r2dbc:h2:file///absolute/file/name`) file name. For `mem` protocol: In-memory database name (`r2dbc:h2:mem:///testdb`).\n| `\u003cwell-known-h2-option\u003e`         | Pass-thru of well-known H2 options such as `DB_CLOSE_DELAY=10\u0026MODE=DB2`. See https://github.com/r2dbc/r2dbc-h2/blob/main/src/main/java/io/r2dbc/h2/H2ConnectionOption.java[`io.r2dbc.h2.H2ConnectionOption`] for all options. _(Optional)_\n| `options`         | A semicolon-delimited list of H2 configuration options(`options=DB_CLOSE_DELAY=10;DB_CLOSE_ON_EXIT=true;…)`. _(Optional)_\n|===\n\n**Programmatic Configuration**\n\n[source,java]\n----\nH2ConnectionFactory connectionFactory = new H2ConnectionFactory(H2ConnectionConfiguration.builder()\n    .inMemory(\"...\")\n    .option(H2ConnectionOption.DB_CLOSE_DELAY, \"-1\")\n    .build());\n\nMono\u003cConnection\u003e connection = connectionFactory.create();\n----\n\n**Programmatic In-Memory Database Configuration**\n\n[source,java]\n----\nCloseableConnectionFactory connectionFactory = H2ConnectionFactory.inMemory(\"testdb\");\n\nMono\u003cConnection\u003e connection = connectionFactory.create();\n----\n\n== Maven\n\nArtifacts can be found on https://search.maven.org/search?q=r2dbc-h2[Maven Central].\n\n[source,xml]\n----\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.r2dbc\u003c/groupId\u003e\n  \u003cartifactId\u003er2dbc-h2\u003c/artifactId\u003e\n  \u003cversion\u003e${version}\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\nIf you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.\n\n[source,xml]\n----\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.r2dbc\u003c/groupId\u003e\n  \u003cartifactId\u003er2dbc-h2\u003c/artifactId\u003e\n  \u003cversion\u003e${version}.BUILD-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n\n\u003crepository\u003e\n  \u003cid\u003esonatype-nexus-snapshots\u003c/id\u003e\n  \u003cname\u003eSonatype OSS Snapshot Repository\u003c/name\u003e\n  \u003curl\u003ehttps://oss.sonatype.org/content/repositories/snapshots\u003c/url\u003e\n\u003c/repository\u003e\n----\n\n== Setting query params\n\nH2 uses index parameters that are prefixed with `$`.\nThe following SQL statement makes use of parameters:\n\n[source,sql]\n----\nINSERT INTO person (id, first_name, last_name) VALUES ($1, $2, $3)\n----\n\nParameters are referenced using the same identifiers when binding these:\n\n[source,java]\n----\nconnection\n    .createStatement(\"INSERT INTO person (id, first_name, last_name) VALUES ($1, $2, $3)\")\n    .bind(\"$1\", 1)\n    .bind(\"$2\", \"Walter\")\n    .bind(\"$3\", \"White\")\n    .execute()\n----\n\n== Geometry support\n\n`r2dbc-h2` will automatically register support for https://locationtech.github.io/jts/[JTS Toplogy Suite] and handle it's `Geometry` types if `org.locationtech.jts:jts-core` is on the classpath.\n\nTo enable, add this to your build:\n\n[source,xml]\n----\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.locationtech.jts\u003c/groupId\u003e\n    \u003cartifactId\u003ejts-core\u003c/artifactId\u003e\n    \u003cversion\u003e${jts.version}\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\nIMPORTANT: Be sure to plug in your version of JTS!\n\nAlso read https://h2database.com/html/datatypes.html#geometry_type[H2's reference documentation] on `GEOMETRY` types.\n\n== We also support params binding as\n\n* index `bind(1, \"Walter\")`.\nNotice that passing an integer means index (zero-based) references.\n* $ symbol `bind(\"$2\", \"Walter\")`.\nH2 supports postgres params notation.\n* Object (Integer) `bind(yourIntegerAsObject, \"Walter\")`.\nIf you index (int) was converted into object by a framework\n\n=== Running JMH Benchmarks\n\nRunning the JMH benchmarks builds and runs the benchmarks without running tests.\n\n[source,bash]\n----\n $ ./mvnw clean install -Pjmh\n----\n\n== Getting Help\n\nHaving trouble with R2DBC? We'd love to help!\n\n* Check the https://r2dbc.io/spec/0.8.1.RELEASE/spec/html/[spec documentation], and https://r2dbc.io/spec/0.8.1.RELEASE/api/[Javadoc].\n* If you are upgrading, check out the https://r2dbc.io/spec/0.8.1.RELEASE/CHANGELOG.txt[changelog] for \"new and noteworthy\" features.\n* Ask a question - we monitor https://stackoverflow.com[stackoverflow.com] for questions\n  tagged with https://stackoverflow.com/tags/r2dbc[`r2dbc`].\n  You can also chat with the community on https://gitter.im/r2dbc/r2dbc[Gitter]\n* Report bugs with R2DBC H2 at https://github.com/r2dbc/r2dbc-h2/issues[github.com/r2dbc/r2dbc-h2/issues].\n\n== Reporting Issues\n\nR2DBC uses GitHub as issue tracking system to record bugs and feature requests.\nIf you want to raise an issue, please follow the recommendations below:\n\n* Before you log a bug, please search the https://github.com/r2dbc/r2dbc-h2/issues[issue tracker] to see if someone has already reported the problem.\n* If the issue doesn't already exist, https://github.com/r2dbc/r2dbc-h2/issues/new[create a new issue].\n* Please provide as much information as possible with the issue report, we like to know the version of R2DBC H2 that you are using and JVM version.\n* If you need to paste code, or include a stack trace use Markdown +++```+++ escapes before and after your text.\n* If possible try to create a test-case or project that replicates the issue.\nAttach a link to your code or a compressed file containing your code.\n\n== Building from Source\n\nYou don't need to build from source to use R2DBC H2 (binaries in Maven Central), but if you want to try out the latest and greatest, R2DBC H2 can be easily built with the\nhttps://github.com/takari/maven-wrapper[maven wrapper].\nYou also need JDK 1.8.\n\n[source,bash]\n----\n $ ./mvnw clean install\n----\n\nIf you want to build with the regular `mvn` command, you will need https://maven.apache.org/run-maven/index.html[Maven v3.5.0 or above].\n\n_Also see https://github.com/r2dbc/.github/blob/main/CONTRIBUTING.adoc[CONTRIBUTING.adoc] if you wish to submit pull requests.\nCommits require `Signed-off-by` (`git commit -s`) to ensure https://developercertificate.org/[Developer Certificate of Origin]._\n\n== Staging to Maven Central\n\nTo stage a release to Maven Central, you need to create a release tag (release version):\n\n. `ci/create-release.sh \u003crelease-version\u003e \u003cnext-snapshot-version\u003e` (e.g. `ci/create-release.sh 0.8.5.RELEASE 0.8.6.BUILD-SNAPSHOT`)\n. `git checkout release`\n. `git reset --hard v\u003crelease-version\u003e` (e.g. `git reset --hard v0.8.5.RELEASE`, observe the `v` prefix)\n. `git push --force`\n\nThis push will trigger a Maven staging build (see `build-and-deploy-to-maven-central.sh`).\n\n== License\n\nThis project is released under version 2.0 of the https://www.apache.org/licenses/LICENSE-2.0[Apache License].\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr2dbc%2Fr2dbc-h2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr2dbc%2Fr2dbc-h2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr2dbc%2Fr2dbc-h2/lists"}