All Projects → r2dbc → R2dbc H2

r2dbc / R2dbc H2

Licence: apache-2.0
R2DBC H2 Implementation

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to R2dbc H2

R2dbc Mysql
R2DBC MySQL Implementation
Stars: ✭ 417 (+253.39%)
Mutual labels:  reactive, reactive-streams, database
R2dbc Spi
Service Provider Interface for R2DBC Implementations
Stars: ✭ 252 (+113.56%)
Mutual labels:  reactive, reactive-streams, database
R2dbc Client
Reactive Relational Database Connectivity
Stars: ✭ 347 (+194.07%)
Mutual labels:  reactive, reactive-streams, database
R2dbc Postgresql
Postgresql R2DBC Driver
Stars: ✭ 714 (+505.08%)
Mutual labels:  reactive, reactive-streams, database
Rxjava2 Jdbc
RxJava2 integration with JDBC including Non-blocking Connection Pools
Stars: ✭ 360 (+205.08%)
Mutual labels:  reactive, reactive-streams, database
Rxcombine
Bi-directional type bridging between RxSwift and Apple's Combine framework
Stars: ✭ 741 (+527.97%)
Mutual labels:  reactive, reactive-streams
Reactivemongo
🍃 Non-blocking, Reactive MongoDB Driver for Scala
Stars: ✭ 825 (+599.15%)
Mutual labels:  reactive, database
Scalecube Services
v2.0 - ScaleCube Services provides a low latency Reactive Microservices library for serverless service registry and discovery based on gossip protocol and without single point-of-failure or bottlenecks.
Stars: ✭ 23 (-80.51%)
Mutual labels:  reactive, reactive-streams
Rxrealm
RxSwift extension for RealmSwift's types
Stars: ✭ 1,007 (+753.39%)
Mutual labels:  reactive, database
Watermelondb
🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
Stars: ✭ 7,996 (+6676.27%)
Mutual labels:  reactive, database
Phantom
Schema safe, type-safe, reactive Scala driver for Cassandra/Datastax Enterprise
Stars: ✭ 1,049 (+788.98%)
Mutual labels:  reactive, reactive-streams
Rdbc
Asynchronous database access for Scala and Java
Stars: ✭ 78 (-33.9%)
Mutual labels:  reactive, database
Servicetalk
A networking framework that evolves with your application
Stars: ✭ 656 (+455.93%)
Mutual labels:  reactive, reactive-streams
Realm Core
Core database component for the Realm Mobile Database SDKs
Stars: ✭ 836 (+608.47%)
Mutual labels:  reactive, database
Rxfirebase
Rxjava 2.0 wrapper on Google's Android Firebase library.
Stars: ✭ 509 (+331.36%)
Mutual labels:  reactive, database
Rxdownloader
- Reactive Extension Library for Android to download files
Stars: ✭ 40 (-66.1%)
Mutual labels:  reactive, reactive-streams
Cyclops
An advanced, but easy to use, platform for writing functional applications in Java 8.
Stars: ✭ 1,180 (+900%)
Mutual labels:  reactive, reactive-streams
Clickhouse Scala Client
Clickhouse Scala Client with Reactive Streams support
Stars: ✭ 84 (-28.81%)
Mutual labels:  reactive, reactive-streams
Alpakka Kafka
Alpakka Kafka connector - Alpakka is a Reactive Enterprise Integration library for Java and Scala, based on Reactive Streams and Akka.
Stars: ✭ 1,295 (+997.46%)
Mutual labels:  reactive, reactive-streams
Akka Grpc
Akka gRPC
Stars: ✭ 361 (+205.93%)
Mutual labels:  reactive, reactive-streams

= Reactive Relational Database Connectivity H2 Implementation

image: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"]

image::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"]

This project contains the https://www.h2database.com/html/main.html[H2] implementation of the https://github.com/r2dbc/r2dbc-spi[R2DBC SPI]. This implementation is not intended to be used directly, but rather to be used as the backing implementation for a humane client library.

This driver provides the following features:

  • Filesystem or in-memory instances
  • Explict transactions
  • Execution of prepared statements with bindings
  • Execution of batch statements without bindings
  • Read and write support for all data types except LOB types (e.g. BLOB, CLOB)

WARNING: Since this driver runs on top of the internals of H2, there is risk of change. r2dbc-h2 does not guarantee compatibility except against the version of H2 found in the build file. Because various parts of H2 are blocking, like file and network access, the only non-blocking assurances are in the layers above H2. Nevertheless, r2dbc-h2 is a great way to warm up to the usage of R2DBC with a small footprint.

== Code of Conduct

This 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:[email protected][[email protected]].

== Getting Started

Here is a quick teaser of how to use R2DBC H2 in Java:

URL Connection Factory Discovery for In-Memory Databases

[source,java]

ConnectionFactory connectionFactory = ConnectionFactories.get("r2dbc:h2:mem:///testdb");

Publisher<? extends Connection> connectionPublisher = connectionFactory.create();

URL Connection Factory Discovery for File Databases

[source,java]

ConnectionFactory connectionFactory = ConnectionFactories.get("r2dbc:h2:file//my/relative/path");

Publisher<? extends Connection> connectionPublisher = connectionFactory.create();

Programmatic Connection Factory Discovery

[source,java]

ConnectionFactoryOptions options = builder() .option(DRIVER, "h2") .option(PROTOCOL, "...") // file, mem .option(HOST, "…") .option(USER, "…") .option(PASSWORD, "…") .option(DATABASE, "…") .build();

ConnectionFactory connectionFactory = ConnectionFactories.get(options);

Publisher<? extends Connection> connectionPublisher = connectionFactory.create();

// Alternative: Creating a Mono using Project Reactor Mono connectionMono = Mono.from(connectionFactory.create());

Supported ConnectionFactory Discovery Options

[%header,cols=2*] |=== | Option | Description | driver | Must be h2. | protocol | Must be file, mem, or tcp. Requires database if set (Optional) | host | Only for tcp protocol: Server hostname to connect to. (Optional) | port | Only for tcp protocol: Server port to connect to. (Optional) | username | Login username. | password | Login password. | 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). | <well-known-h2-option> | Pass-thru of well-known H2 options such as DB_CLOSE_DELAY=10&MODE=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) | options | A semicolon-delimited list of H2 configuration options(options=DB_CLOSE_DELAY=10;DB_CLOSE_ON_EXIT=true;…). (Optional) |===

Programmatic Configuration

[source,java]

H2ConnectionFactory connectionFactory = new H2ConnectionFactory(H2ConnectionConfiguration.builder() .inMemory("...") .option(H2ConnectionOption.DB_CLOSE_DELAY, "-1") .build());

Mono connection = connectionFactory.create();

Programmatic In-Memory Database Configuration

[source,java]

CloseableConnectionFactory connectionFactory = H2ConnectionFactory.inMemory("testdb");

Mono connection = connectionFactory.create();

== Maven

Artifacts can be found on https://search.maven.org/search?q=r2dbc-h2[Maven Central].

[source,xml]

io.r2dbc r2dbc-h2 ${version} ----

If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.

[source,xml]

io.r2dbc r2dbc-h2 ${version}.BUILD-SNAPSHOT sonatype-nexus-snapshots Sonatype OSS Snapshot Repository https://oss.sonatype.org/content/repositories/snapshots ----

== Setting query params

H2 uses index parameters that are prefixed with $. The following SQL statement makes use of parameters:

[source,sql]

INSERT INTO person (id, first_name, last_name) VALUES ($1, $2, $3)

Parameters are referenced using the same identifiers when binding these:

[source,java]

connection .createStatement("INSERT INTO person (id, first_name, last_name) VALUES ($1, $2, $3)") .bind("$1", 1) .bind("$2", "Walter") .bind("$3", "White") .execute()

== Geometry support

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.

To enable, add this to your build:

[source,xml]

org.locationtech.jts jts-core ${jts.version} ----

IMPORTANT: Be sure to plug in your version of JTS!

Also read https://h2database.com/html/datatypes.html#geometry_type[H2's reference documentation] on GEOMETRY types.

== We also support params binding as

  • index bind(1, "Walter"). Notice that passing an integer means index (zero-based) references.
  • $ symbol bind("$2", "Walter"). H2 supports postgres params notation.
  • Object (Integer) bind(yourIntegerAsObject, "Walter"). If you index (int) was converted into object by a framework

=== Running JMH Benchmarks

Running the JMH benchmarks builds and runs the benchmarks without running tests.

[source,bash]

$ ./mvnw clean install -Pjmh

== Getting Help

Having trouble with R2DBC? We'd love to help!

== Reporting Issues

R2DBC uses GitHub as issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:

  • 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.
  • If the issue doesn't already exist, https://github.com/r2dbc/r2dbc-h2/issues/new[create a new issue].
  • 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.
  • If you need to paste code, or include a stack trace use Markdown +++```+++ escapes before and after your text.
  • If possible try to create a test-case or project that replicates the issue. Attach a link to your code or a compressed file containing your code.

== Building from Source

You 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 https://github.com/takari/maven-wrapper[maven wrapper]. You also need JDK 1.8.

[source,bash]

$ ./mvnw clean install

If 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].

Also see https://github.com/r2dbc/.github/blob/main/CONTRIBUTING.adoc[CONTRIBUTING.adoc] if you wish to submit pull requests. Commits require Signed-off-by (git commit -s) to ensure https://developercertificate.org/[Developer Certificate of Origin].

== Staging to Maven Central

To stage a release to Maven Central, you need to create a release tag (release version) that contains the desired state and version numbers (mvn versions:set versions:commit -q -o -DgenerateBackupPoms=false -DnewVersion=x.y.z.(RELEASE|Mnnn|RCnnn) and force-push it to the release-0.x branch. This push will trigger a Maven staging build (see build-and-deploy-to-maven-central.sh).

== License

This project is released under version 2.0 of the https://www.apache.org/licenses/LICENSE-2.0[Apache License].

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].