The main goal for this project is to implement simple, async, performant and reliable database drivers for PostgreSQL and MySQL in Kotlin. This is not supposed to be a JDBC replacement, these drivers aim to cover the common process of send a statement, get a response that you usually see in applications out there. So it's unlikely there will be support for updating result sets live or stuff like that.
// Connect to DB
Connection connection = new MySQLConnection(
new Configuration(
"username",
"host.com",
3306,
"password",
"schema"
)
);
CompletableFuture<?> connectFuture = connection.connect()
// Wait for connection to be ready
// ...
// Execute query
CompletableFuture<QueryResult> future = connection.sendPreparedStatement("select * from table");
// Close the connection
connection.disconnect().get()
See a full example at jasync-mysql-example.
<dependency>
<groupId>com.github.jasync-sql</groupId>
<artifactId>jasync-mysql</artifactId>
<version>0.8.21</version>
</dependency>
<!-- add jcenter repo: -->
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
dependencies {
compile 'com.github.jasync-sql:jasync-mysql:0.8.21'
}
// add jcenter repo:
repositories {
jcenter()
}
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 CHANGELOG here.
- Open an issue here: https://github.com/jasync-sql/jasync-sql/issues
- Chat on gitter: https://gitter.im/jasync-sql/support
- How we started.
- https://github.com/mauricio/postgresql-async - The original (deprecated) lib.
- Async database access with MySQL, Kotlin and jasync-sql
Pull requests are welcome!
See CONTRIBUTING.