Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try-with-Resources Not Closing Database Connections for One Select Query #2213

Open
baliyanshilpa04 opened this issue Jul 2, 2024 · 3 comments

Comments

@baliyanshilpa04
Copy link

Facing an issue with try-with-resources as it is not closing the database connections automatically particularly for one select query while working for other queries of the same class within a java application. Please suggest what could be the issue here.
Steps to Reproduce
Execute the problematic select query using the try-with-resources statement.
Monitor the database connections to observe that the connection is not closed.
Execute other queries in the same class to confirm that their connections are closed properly.
Expected Behavior
The database connection should be automatically closed after the try-with-resources block for all queries.

Actual Behavior
The database connection remains open for one specific select query, causing potential resource leaks.

@baliyanshilpa04
Copy link
Author

Any comments please??

@IRus
Copy link

IRus commented Aug 16, 2024

@baliyanshilpa04 why do you think connection should be closed? Please provide a configuration and test that reproduces described behavior

@PavlovIvan
Copy link

@baliyanshilpa04 HikariCP reuses connections. When you call the method close you will return the connection to the pool, but the physical connection to the database will still exist.
Look at com.zaxxer.hikari.pool.ProxyConnection for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants