Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Getting Started

Ohad Shai edited this page Nov 20, 2018 · 5 revisions
// 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.

Download

Maven

<!-- mysql -->
<dependency>
  <groupId>com.github.jasync-sql</groupId>
  <artifactId>jasync-mysql</artifactId>
  <version>x.y.z</version>
</dependency>
<!-- postgresql -->
<dependency>
  <groupId>com.github.jasync-sql</groupId>
  <artifactId>jasync-postgresql</artifactId>
  <version>x.y.z</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:x.y.z'
  // postgresql
  compile 'com.github.jasync-sql:jasync-postgresql:x.y.z'
}
// add jcenter repo:
repositories {
    jcenter()
}
Clone this wiki locally