Asynchronous PostgreSQL Java driver

pgAsync

A non-blocking PostgreSQL driver with connection pooling, prepared statements, transactions, standard SQL type support, and custom converters.

Client CompletableFuture API
PostgreSQL Protocol v3
pool.completeQuery(
  "select count(*) cnt from cp_test"
).thenAccept(resultSet -> {
  int count = resultSet.at(0).getInt("cnt");
});
Non-blocking Built around asynchronous query execution.
PostgreSQL focused Implements PostgreSQL protocol messages directly.
Testcontainers ready Integration tests start Postgres automatically.

Install

Add the source dependency

The project is published as a Gradle source dependency. Add the Git repository to `settings.gradle.kts`, then depend on the module from your build file.

settings.gradle.kts
sourceControl {
  gitRepository(uri("https://github.com/AlekseiDudchenko/postgres-async-driver.git")) {
    producesModule("com.github.pgasync:postgres-async-driver")
  }
}
build.gradle.kts
dependencies {
  implementation("com.github.pgasync:postgres-async-driver:v1.0.5")
}

Usage

Run queries through a connectible pool

The public API lives in `com.pgasync`; implementation classes live under `com.github.pgasync`.

Query example
Connectible pool = new NettyConnectibleBuilder()
    .database("postgres")
    .username("postgres")
    .password("postgres")
    .ssl(true)
    .maxConnections(4)
    .pool();

pool.completeQuery("select count(*) cnt from cp_test")
    .thenAccept(resultSet -> {
      Row row = resultSet.at(0);
      int count = row.getInt("cnt");
    });

Connection Pooling

Reuse PostgreSQL connections and execute concurrent asynchronous work.

Prepared Statements

Bind parameters and keep query execution explicit at the API boundary.

Transactions

Begin, commit, and roll back transactional units with future-based flows.

Custom Converters

Extend type handling for application-specific PostgreSQL values.

Testing

Run the local test suite

Tests use JUnit 4 and Testcontainers for PostgreSQL. Start Docker Desktop first; Testcontainers will pull and run `postgres:11` automatically.

PowerShell
docker info
.\gradlew.bat test --no-daemon