Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jasync-sql/jasync-sql

Java & Kotlin Async DataBase Driver for MySQL and PostgreSQL written in Kotlin
https://github.com/jasync-sql/jasync-sql

async-jdbc jdbc jdbc-driver mysql-driver postgresql-driver reactive sql

Last synced: about 1 month ago
JSON representation

Java & Kotlin Async DataBase Driver for MySQL and PostgreSQL written in Kotlin

Awesome Lists containing this project

README

        

[![Chat at https://gitter.im/jasync-sql/support](https://badges.gitter.im//jasync-sql/support.svg)](https://gitter.im/jasync-sql/support) [![Maven Central](https://img.shields.io/maven-central/v/com.github.jasync-sql/jasync-common.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.jasync-sql%22%20AND%20a:%22jasync-common%22) ![Build Status](https://github.com/jasync-sql/jasync-sql/actions/workflows/ci.yml/badge.svg?branch=master) [![Apache License V.2](https://img.shields.io/badge/license-Apache%20V.2-blue.svg)](https://github.com/jasync-sql/jasync-sql/blob/master/LICENSE) [![codecov](https://codecov.io/gh/jasync-sql/jasync-sql/branch/master/graph/badge.svg)](https://codecov.io/gh/jasync-sql/jasync-sql) [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin#libraries-frameworks-database)

[jasync-sql](https://github.com/jasync-sql/jasync-sql) is a Simple, Netty based, asynchronous, performant and reliable database drivers for
PostgreSQL and MySQL written in Kotlin.

[Show your ❤ with a ★](https://github.com/jasync-sql/jasync-sql/stargazers)

## Getting started

```Java
// Connection to MySQL DB
Connection connection = MySQLConnectionBuilder.createConnectionPool(
"jdbc:mysql://$host:$port/$database?user=$username&password=$password");

// Connection to PostgreSQL DB
Connection connection = PostgreSQLConnectionBuilder.createConnectionPool(
"jdbc:postgresql://$host:$port/$database?user=$username&password=$password");
// Execute query
CompletableFuture future = connection.sendPreparedStatement("select * from table");
// work with result ...
// Close the connection pool
connection.disconnect().get()
```

See a full example at [jasync-mysql-example](https://github.com/jasync-sql/jasync-mysql-example) and [jasync-postgresql-example](https://github.com/jasync-sql/jasync-postgresql-example).
More samples on the [samples dir](https://github.com/jasync-sql/jasync-sql/tree/master/samples).

For docs and info see the [wiki](https://github.com/jasync-sql/jasync-sql/wiki).

## Download

### Maven

```xml

com.github.jasync-sql
jasync-mysql
2.2.0

com.github.jasync-sql
jasync-postgresql
2.2.0

```

### Gradle

```gradle
dependencies {
// mysql
compile 'com.github.jasync-sql:jasync-mysql:2.2.0'
// postgresql
compile 'com.github.jasync-sql:jasync-postgresql:2.2.0'
}
```

### Additional Modules

- `com.github.jasync-sql:jasync-r2dbc-mysql` r2dbc extension.
- `com.github.jasync-sql:postgis-jasync` spatial types support for postgres + postgis.
- `com.github.jasync-sql:pool-async` async objects pool.
- `com.github.jasync-sql:db-async-common` internal module for shared logic.

## Overview

This project is a port of [mauricio/postgresql-async](https://github.com/mauricio/postgresql-async) to Kotlin.
Why? Because the original lib is not maintained anymore, We use it in [ob1k](https://github.com/outbrain/ob1k), and would like to remove the Scala dependency in ob1k.

If you want information specific to the drivers, check the [PostgreSQL README](postgresql-async/README.md) and the
[MySQL README](mysql-async/README.md).

You can view the project's change log [here](CHANGELOG.md).

**Follow us on twitter: [@jasyncs](https://twitter.com/Jasyncs).**

#### DateTime:
Version 1.x always returns [JodaTime](http://joda-time.sourceforge.net/) when dealing with date types and not the
`java.util.Date` class nor jdk-8 dates.
Version 2.x works with java 8 DateTime objects (`java.time.LocalDateTime` and such).
This [post](https://blog.joda.org/2014/11/converting-from-joda-time-to-javatime.html) can help with migration.

## Who is using it

* [R2DBC](https://r2dbc.io/)
* [Spring Data R2DBC](https://spring.io/projects/spring-data-r2dbc)
* [Vert.x](https://github.com/vert-x3/vertx-mysql-postgresql-client)
* [micronaut](https://github.com/micronaut-projects/micronaut-sql)
* [Outbrain/ob1k-db](https://github.com/outbrain/ob1k/)
* https://github.com/humb1t/jpom
* [Zeko Data Mapper](https://github.com/darkredz/Zeko-Data-Mapper) and [Zeko SQL Builder](https://github.com/darkredz/Zeko-SQL-Builder)
* [vertx-jooq async module](https://github.com/jklingsporn/vertx-jooq)
* [ScalikeJDBC Async](https://github.com/scalikejdbc/scalikejdbc-async)
* [Quill](https://getquill.io/)
* [Jasync SQL Extensions](https://github.com/28Smiles/jasync-sql-extensions)

Add your name here!

Is it used in production on large scale?

jasync-sql-production

The graph above is from only couple of services using it. Y-Axis is # of queries per minute.

There is also a [TechEmpower test](https://github.com/TechEmpower/FrameworkBenchmarks/pull/4247) using `ktor` and `jasync-sql`.

[Zeko SQL Builder](https://github.com/darkredz/Zeko-SQL-Builder#performance) compared jasync to hikary and vertex:
jasync-sql-zeko

## Compatibility

Latest & greatest version is [![Maven Central](https://img.shields.io/maven-central/v/com.github.jasync-sql/jasync-common.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.jasync-sql%22%20AND%20a:%22jasync-common%22)

The driver was forked from [mauricio/postgresql-async](https://github.com/mauricio/postgresql-async) and is compatible with it (but not jdbc compatible!). More details in [wiki](https://github.com/jasync-sql/jasync-sql/wiki/Mauricio-Driver-Migration).

**R2DBC**:
- Initial support in jasync 0.9.51.
- Support for 0.8 released version since jasync 1.0.12.
- Upgrade to GA 1.0 R2DBC (spring boot >= 3) was done in jasync 2.1.0. jaync-sql 2.0.8 will be the last version that's compatible with r2dbc <= 0.9.1. See also [FAQ](https://github.com/jasync-sql/jasync-sql/wiki/FAQ#q-is-r2dbc-version--1-supported).

[Postgis](https://postgis.net/) support added in 2.1.7 (see [blog post](https://ohadshai.medium.com/postgis-in-jasync-10264fc7fac2)).

[Unix domain socket](https://en.wikipedia.org/wiki/Unix_domain_socket) support was added in 2.1.6 (see [#175](https://github.com/jasync-sql/jasync-sql/issues/175)).

Chanlog is currently documented in github [release page](https://github.com/jasync-sql/jasync-sql/releases). Previous ones can be found [here](https://github.com/jasync-sql/jasync-sql/blob/master/CHANGELOG.md) and older [here](https://github.com/jasync-sql/jasync-sql/blob/master/the-old-files/CHANGELOG-old.md).

Notable changes:
- First driver release is version 0.8.20.
- First driver release to maven is 1.0.0.
- Migrating from joda to java 8 times was done in 2.0.0 (see [#233](https://github.com/jasync-sql/jasync-sql/pull/233)). Versions <= 2.0 are not suppoprted anymore.

## Support

* Check [FAQ](https://github.com/jasync-sql/jasync-sql/wiki/FAQ) or [Known Issues](https://github.com/jasync-sql/jasync-sql/wiki/Known-Issues) or [google](https://www.google.com/search?q=jasync-sql).
* Open an issue here: https://github.com/jasync-sql/jasync-sql/issues
* Chat on gitter: https://gitter.im/jasync-sql/support
* Ask a question in StackOverflow with [jasync-sql](https://stackoverflow.com/questions/tagged/jasync-sql) tag.

## More links

* [How we cloned the original lib](https://hackernoon.com/how-i-ported-10k-lines-of-scala-to-kotlin-in-one-week-c645732d3c1).
* https://github.com/mauricio/postgresql-async - The original (deprecated) lib.
* [Async database access with MySQL, Kotlin and jasync-sql](https://medium.com/@OhadShai/async-database-access-with-mysql-kotlin-and-jasync-sql-dbfdb8e7fd04).
* [Issue with NUMERIC](https://medium.com/@OhadShai/sometimes-a-small-bug-fix-can-lead-to-an-avalanche-f6ded2ecf53d).
* [jasync-sql + javalin example](https://medium.com/@OhadShai/reactive-java-all-the-way-to-the-database-with-jasync-sql-and-javalin-c982365d7dd2).
* [jasync-sql + ktor + coroutines example](https://medium.com/@OhadShai/async-with-style-kotlin-web-backend-with-ktor-coroutines-and-jasync-mysql-b34e8c83e4bd).
* [jasync-sql + spring + kotlin example](https://github.com/godpan/spring-kotlin-jasync-sql).
* [How to implement an Object Pool with an Actor in Kotlin](https://medium.freecodecamp.org/how-to-implement-an-object-pool-with-an-actor-in-kotlin-ed06d3ba6257).
* [Coroutines usage](https://medium.com/@OhadShai/just-a-small-example-of-how-kotlin-coroutines-are-great-c9774fe8434).
* [Spring Data R2DBC video](https://www.youtube.com/watch?v=DvO4zLVDkMs).
* [JDBC for Spring WebFlux: Spring Data R2DBC](https://medium.com/w-logs/jdbc-for-spring-webflux-spring-data-r2dbc-99690208cfeb).
* [Spring WebFlux는 어떻게 적은 리소스로 많은 트래픽을 감당할까?](https://alwayspr.tistory.com/44).

## Contributing

Pull requests are welcome!
See [CONTRIBUTING](CONTRIBUTING.md).