0
votes

I'm having this problem no matter what dependency I import. I followed the guide in https://quarkus.io/guides/reactive-postgres-client. Using another dependency - not "by" Quarkus, for example - doesn't solve it either. It's in this piece of code:

private void initDatabase() {
    client.query("DROP TABLE IF EXISTS fruits")
            .thenCompose(r -> client.query("CREATE TABLE fruits (id SERIAL PRIMARY KEY, name TEXT NOT NULL)"))
            .thenCompose(r -> client.query("INSERT INTO fruits (name) VALUES ('Orange')"))
            .thenCompose(r -> client.query("INSERT INTO fruits (name) VALUES ('Pear')"))
            .thenCompose(r -> client.query("INSERT INTO fruits (name) VALUES ('Apple')"))
            .toCompletableFuture()
            .join();
}
1
double check your imports for whatever type client is. You've likely imported io.vertx dependencies but instead need to import the io.smallrye.mutiny equivalent - Andy Guibert
Same result. The options for import are: 1) io.vertx.mutiny.pgclient; 2) io.vertx.axle.pgclient; 3) io.vertx.reactivex.pgclient; and 4) io.vertx.pgclient. - Rasshu

1 Answers

1
votes

This page is no longer valid, I'm not sure why it wasn't deleted from the website. Here's the updated one: https://quarkus.io/guides/reactive-sql-clients

With Quarkus in most cases you should use io.vertx.mutiny.pgclient.PgPool.

The method implementation is:

private void initdb() {
    client.query("DROP TABLE IF EXISTS fruits").execute()
            .flatMap(r -> client.query("CREATE TABLE fruits (id SERIAL PRIMARY KEY, name TEXT NOT NULL)").execute())
            .flatMap(r -> client.query("INSERT INTO fruits (name) VALUES ('Kiwi')").execute())
            .flatMap(r -> client.query("INSERT INTO fruits (name) VALUES ('Durian')").execute())
            .flatMap(r -> client.query("INSERT INTO fruits (name) VALUES ('Pomelo')").execute())
            .flatMap(r -> client.query("INSERT INTO fruits (name) VALUES ('Lychee')").execute())
            .await().indefinitely();
}