-
I want to display the contents of the ids column, but it is not displayed, and also does not give any error. private static final String GET_DATA = "SELECT * FROM public.user";
public static @NotNull ConnectionFactory init() {
return ConnectionFactories.get(ConnectionFactoryOptions.builder()
.option(DRIVER, "postgresql")
.option(HOST, "localhost")
.option(PORT, 5432)
.option(USER, "postgres")
.option(PASSWORD, "postgres")
.option(DATABASE, "user")
.build());
}
public static void main(String[] args) {
Mono.from(init().create())
.map(connection -> getFlux(connection).toList())
.doOnError(error -> error.printStackTrace())
.subscribe(System.out::println);
}
public static Stream<String> getFlux(@NotNull Connection connection) {
return Flux.from(connection.createStatement(GET_DATA).execute())
.doOnError(error -> error.printStackTrace())
.flatMap(result -> result.map((row, rowMetadata) -> row.get("ids", String.class)))
.toStream();
} |
Beta Was this translation helpful? Give feedback.
Answered by
Squiry
Dec 23, 2023
Replies: 1 comment 1 reply
-
Add a Thread.sleep or use a block instead of subscribe. Also, do not use toStream in a reactive code. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
AdaMorgan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add a Thread.sleep or use a block instead of subscribe. Also, do not use toStream in a reactive code.