Closed kokosing closed 2 years ago
Notably MySQL and SQL Server don't cancel the query this way. SQL Server driver tries to drain the connection and MySQL waits for a client timeout (configurable on the server).
It is not well specified by JDBC standard as JDBC Connection#close javadoc says:
Please check the JDBC spec. I recall seeing somewhere that connection close must implciitly close statements and results sets.
9.4.4.1 Connection.close An application calls the method Connection.close() to indicate that it has finished using a connection. All Statement objects created from a given Connection object will be closed when the close method for the Connection object is called.
They mention that it should close Statement
which means:
Closing Statement Objects An application calls the method Statement.close to indicate that it has finished processing a statement. All Statement objects will be closed when the connection that created them is closed. However, it is good coding practice for applications to close statements as soon as they have finished processing them. This allows any external resources that the statement is using to be released immediately.
Then, it is a bug.
Closing as #7819. #7918 should be handled as a separated issue.
It is not well specified by JDBC standard as JDBC Connection#close javadoc says:
See
If the close method is called and there is an active transaction, the results are implementation-defined.
.However this is the way DBeaver cancel the running query, by closing the connection and they claim it works this way for MySQL, PostgreSQL, Oracle and others in https://github.com/dbeaver/dbeaver/issues/3094#issuecomment-628222837