Thread interruption and concurrent close
Douglas Surber
douglas.surber at oracle.com
Thu May 15 15:41:22 UTC 2025
The intended way to handle this is to call Connection.abort(Executor) on the offending Connections. This method will mark the Connection as closed and return quickly. It may also schedule a task to perform any long running work appropriate to actually shutdown and clean up the Connection and its resources. Because the Connection may be in use, and thus locks held, cleaning up the Connection may not take place until the locks are released perhaps after the socket timeout. The default socket timeout is something like 15 minutes so this can take a while.
Douglas Surber
<https://docs.oracle.com/en/java/javase/23/docs/api/java.sql/java/sql/Connection.html#abort(java.util.concurrent.Executor)>
Connection (Java SE 23 & JDK 23)<https://docs.oracle.com/en/java/javase/23/docs/api/java.sql/java/sql/Connection.html#abort(java.util.concurrent.Executor)>
docs.oracle.com<https://docs.oracle.com/en/java/javase/23/docs/api/java.sql/java/sql/Connection.html#abort(java.util.concurrent.Executor)>
[favicon.ico]<https://docs.oracle.com/en/java/javase/23/docs/api/java.sql/java/sql/Connection.html#abort(java.util.concurrent.Executor)>
On May 13, 2025, at 11:27 AM, Pavel Rappo <pavel.rappo at gmail.com> wrote:
Is it specified how JDBC methods should react to thread interruption
and concurrent closure of the connection?
As a JDBC user, I'm trying to figure out my best course of action in
the following scenario. A statement has been executing for a while
when the application shutdown hook starts. The hook should quickly
shut down everything and return.
-Pavel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jdbc-spec-discuss/attachments/20250515/caa146bb/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: favicon.ico
Type: image/vnd.microsoft.icon
Size: 10134 bytes
Desc: favicon.ico
URL: <https://mail.openjdk.org/pipermail/jdbc-spec-discuss/attachments/20250515/caa146bb/favicon-0001.ico>
More information about the jdbc-spec-discuss
mailing list