jasync-sql is a Simple, Netty based, asynchronous, performant and reliable database drivers for PostgreSQL and MySQL written in Kotlin.
Getting started
// Connection to MySQL DB
Connection connection = new 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.
Download
- Note: The regular artifact is netty 4.1. Netty 4.0 version looks like this
0.8.59-netty4.0
etc'.0.8.59-netty4.0
is currently the latest netty 4.0 version.
Maven
<!-- mysql -->
<dependency>
<groupId>com.github.jasync-sql</groupId>
<artifactId>jasync-mysql</artifactId>
<version>0.8.64</version>
</dependency>
<!-- postgresql -->
<dependency>
<groupId>com.github.jasync-sql</groupId>
<artifactId>jasync-postgresql</artifactId>
<version>0.8.64</version>
</dependency>
<!-- add jcenter repo: -->
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
Gradle
dependencies {
// mysql
compile 'com.github.jasync-sql:jasync-mysql:0.8.64'
// postgresql
compile 'com.github.jasync-sql:jasync-postgresql:0.8.64'
}
// add jcenter repo:
repositories {
jcenter()
}
Overview
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.
This project always returns JodaTime when dealing with date types and not the java.util.Date
class. (We plan to move to jdk-8 dates).
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.
Who is using it
Add your name here!
Support
- 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 tag.
More links
- How we cloned the original lib.
- https://github.com/mauricio/postgresql-async - The original (deprecated) lib.
- Async database access with MySQL, Kotlin and jasync-sql.
- Issue with NUMERIC.
- jasync-sql + javalin example.
- jasync-sql + ktor + coroutines example.
- jasync-sql + spring + kotlin example.
- How to implement an Object Pool with an Actor in Kotlin.
- Coroutines usage.
Contributing
Pull requests are welcome!
See CONTRIBUTING.