Java & Kotlin Async DataBase Driver for MySQL and PostgreSQL written in Kotlin
jasync-sql is a Simple, Netty based, asynchronous, performant and reliable database drivers for
PostgreSQL and MySQL written in Kotlin.
// 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<QueryResult> future = connection.sendPreparedStatement("select * from table");
// work with result ...
// Close the connection pool
connection.disconnect().get()
See a full example at jasync-mysql-example and jasync-postgresql-example.
More samples on the samples dir.
For docs and info see the wiki.
<!-- mysql -->
<dependency>
<groupId>com.github.jasync-sql</groupId>
<artifactId>jasync-mysql</artifactId>
<version>2.2.4</version>
</dependency>
<!-- postgresql -->
<dependency>
<groupId>com.github.jasync-sql</groupId>
<artifactId>jasync-postgresql</artifactId>
<version>2.2.4</version>
</dependency>
dependencies {
// mysql
compile 'com.github.jasync-sql:jasync-mysql:2.2.4'
// postgresql
compile 'com.github.jasync-sql:jasync-postgresql:2.2.4'
}
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.This project is a port of mauricio/postgresql-async to Kotlin.
Why? Because the original lib is not maintained anymore, We use it in ob1k, and would like to remove the Scala dependency in ob1k.
If you want information specific to the drivers, check the PostgreSQL README and the
MySQL README.
You can view the project’s change log here.
Follow us on twitter: @jasyncs.
Version 1.x always returns JodaTime 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 can help with migration.
Add your name here!
Is it used in production on large scale?
The graph above is from only couple of services using it. Y-Axis is # of queries per minute.
There is also a TechEmpower test using ktor
and jasync-sql
.
Zeko SQL Builder compared jasync to hikary and vertex:
The driver was forked from mauricio/postgresql-async and is compatible with it (but not jdbc compatible!). More details in wiki.
R2DBC:
Postgis support added in 2.1.7 (see blog post).
Unix domain socket support was added in 2.1.6 (see #175).
Chanlog is currently documented in github release page. Previous ones can be found here and older here.
Notable changes:
Pull requests are welcome!
See CONTRIBUTING.