Reputation: 1
I use the quarkus framework, integrate hibernate reactive, and use the panache list method to query. I find that it do not use the connection pool, but use the connection directly. As a result, the query cannot be used after the connection is closed.
SqlClientConnection
public CompletionStage<RowSet<Row>> preparedQuery(String sql, Tuple parameters) {
feedback(sql);
String processedSql = usePostgresStyleParameters ? Parameters.process( sql, parameters.size() ) : sql;
return Handlers.toCompletionStage(
handler -> client().preparedQuery( processedSql ).execute( parameters, handler )
);
}
PanacheQueryImpl
@Override
public <T extends Entity> Uni<List<T>> list() {
return delegate.list();
}
I'd like to know how to use pool when querying?
Upvotes: 0
Views: 1143
Reputation: 6107
Technically it doesn't need a traditional connection pool, because all operations are non-blocking, so you can easily saturate your CPU completely with a single connection to the database.
In practice the default is to use a single connection for each Vert.x context, and by default you'll have two such contexts per CPU.
When you say "query cannot be used after the connection is closed" I suspect you're actually hitting a bug we fixed recently; please add more details to a new question; I suspect the solution for your issue (in that case) is that you need to use Panache Reactive from a non-blocking context, such as using RESTEasy Reactive for your endpoint.
Upvotes: 1