<dependency>
<groupId>io.reactiverse</groupId>
<artifactId>postgresql-async</artifactId>
<version>0.10.0</version>
</dependency>
import io.reactiverse.pgclient.PgClient;
import io.reactiverse.pgclient.PgConnection;
import io.vertx.core.Vertx;
public class AsyncDatabaseConnector {
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
PgConnection.connect(vertx, "postgresql://localhost:5432/database_name", "username", "password", asyncResult -> {
if (asyncResult.succeeded()) {
PgConnection connection = asyncResult.result();
} else {
}
});
}
}
import io.reactiverse.pgclient.PgResult;
import io.reactiverse.pgclient.Row;
import io.reactiverse.pgclient.Tuple;
public class AsyncQueryExecutor {
public static void main(String[] args) {
PgConnection connection = getConnection();
connection.preparedQuery("SELECT * FROM table_name WHERE column = $1")
.execute(Tuple.of("value"), asyncResult -> {
if (asyncResult.succeeded()) {
PgResult<Row> result = asyncResult.result();
for (Row row : result) {
}
} else {
}
});
}
}