Thread interruption and concurrent close

Pavel Rappo pavel.rappo at gmail.com
Fri May 16 16:50:57 UTC 2025


Okay, so Connection.abort(Executor) is a safe way to initialise the
connection closure. Is there any example use of that method available?
Separately, JDBC seems to be silent on threading. Those few methods that
take Executor seem to have been added relatively recently.

On Thu, May 15, 2025 at 4:41 PM Douglas Surber <douglas.surber at oracle.com>
wrote:

> 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
>
> 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)>
> [image: favicon.ico]
> <https://docs.oracle.com/en/java/javase/23/docs/api/java.sql/java/sql/Connection.html#abort(java.util.concurrent.Executor)>
> <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/20250516/5da13902/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: favicon.ico
Type: application/octet-stream
Size: 10134 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/jdbc-spec-discuss/attachments/20250516/5da13902/favicon.ico>


More information about the jdbc-spec-discuss mailing list