brettwooldridge / HikariCP

光 HikariCP・A solid, high-performance, JDBC connection pool at last.
Apache License 2.0
19.91k stars 2.92k forks source link

ProxyConnection should close when ProxyStatement close #2146

Closed soosue closed 10 months ago

soosue commented 10 months ago

If a connection is not closed, the PoolEntry remains in the IN_USE state, leading to a connection leak.

quaff commented 10 months ago

Connection 1:n Statement, I don't understand why Connection should be closed when Statement close.

lfbayer commented 10 months ago

@quaff I agree. This pull request is definitely not correct.

The connection absolutely should not be closed when a statement is closed as that would, along with potentially thousands of other problems, prevent users from using multiple statements for a single connection.

@soosue, what you want to do is close your connection in your application code explicitly after you have finished with it, you should not expect a statement close to close a connection for you. A try-with-resources block with the connection is the most idiomatic way to achieve this.

I'm marking this as closed.