How to Handle Connection Pool Timeout in HikariCP with Java 17 and Spring Boot?
I'm relatively new to this, so bear with me. I've tried everything I can think of but I'm using HikariCP as a connection pool for my Spring Boot application (version 2.7.5) with Java 17. Recently, I started working with a `HikariPoolTimedOutException: Timeout after 30 seconds of waiting for a connection` when my application is under load. The configuration for HikariCP is as follows: ```yaml spring: datasource: url: jdbc:mysql://localhost:3306/mydb username: user password: password hikari: maximum-pool-size: 10 connection-timeout: 30000 idle-timeout: 600000 max-lifetime: 1800000 ``` I have tried increasing the `maximum-pool-size` to 20, but the scenario still continues. When I monitor the database connections, it seems that the connections are not being released properly after use. I added the following code to close connections explicitly, but it doesn't seem to have any effect: ```java try (Connection connection = dataSource.getConnection()) { // some database operations } catch (SQLException e) { e.printStackTrace(); } ``` I also checked for any long-running queries in the database that could be blocking connections, but nothing stands out in the logs. Is there a specific configuration that I might be overlooking, or a best practice for managing connection lifecycles in this scenario? Any guidance would be appreciated! The project is a mobile app built with Java. Thanks, I really appreciate it! My development environment is Ubuntu 20.04. Any help would be greatly appreciated!