You can configure the maximum size of connections by setting the spring.datasource.hikari.maximum-pool-size
property. By default, this is set to 10. Before you increase this, it's recommended that you read the About Pool Sizing documentation of Hikari first.
However, if your goal is to create a new connection for every query you execute, then the answer is that it isn't possible. The way connection pools like Hikari work is that they create a pool of connections ready to be used when the application starts. The default value of this is also 10 (configured through spring.datasource.hikari.minimum-idle
). Hikari will then maintain these connections (checking whether they're alive, creating new ones if existing ones reach their maximum life time, ...).
So for your query SELECT 1 FROM DUAL
, it means that Hikari will take one of its connections that's free, and executes the query using that connection. If all connections are busy and spring.datasource.hikari.maximum-pool-size
isn't reached, then it will create a new connection.
However, since spring.datasource.hikari.minimum-idle
and spring.datasource.hikari.maximum-pool-size
are the same by default, it means that Hikari won't create a new connection after startup unless it's to replace an existing one. Hikari also recommends to keep these two the same values, as mentioned within the documentation (search for "fixed size connection pool").
If all connections are busy and spring.datasource.hikari.maximum-pool-size
is reached, then it waits until one is freed up (by default 30 seconds). If no connection is freed up, then an exception is thrown. Summarized, Hikari won't create a new connection for each call.
spring.datasource.hikari.minimum-idle
property, this will control how many connections Hikari will open at the start of the application (default 10). Thespring.datasource.hikari.maximum-pool-size
controls the maximum (default 10). If you increase the poolsize you also need to increase the max (as minimum cannot be higher than maximum). I would also suggest on studying how a connection pool works as your question and how you tried to solve this indicate you don't understand those. – Planarian