<div dir="ltr">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.</div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, May 15, 2025 at 4:41 PM Douglas Surber <<a href="mailto:douglas.surber@oracle.com">douglas.surber@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div style="line-break:after-white-space">
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.
<div><br>
</div>
<div>Douglas Surber<br>
<div><br>
</div>
<div>
<div style="display:block">
<div style="display:inline-block" role="link">
<a style="border-radius:10px;font-family:-apple-system,Helvetica,Arial,sans-serif;display:block;width:300px;overflow:hidden;text-decoration:none" rel="nofollow" href="https://docs.oracle.com/en/java/javase/23/docs/api/java.sql/java/sql/Connection.html#abort(java.util.concurrent.Executor)" dir="ltr" role="button" width="300" target="_blank">
<table style="table-layout:fixed;border-collapse:collapse;width:300px;background-color:rgb(212,25,32);font-family:-apple-system,Helvetica,Arial,sans-serif" cellpadding="0" cellspacing="0" border="0" width="300">
<tbody>
<tr>
<td>
<table bgcolor="#D41920" cellpadding="0" cellspacing="0" width="300" style="table-layout:fixed;font-family:-apple-system,Helvetica,Arial,sans-serif;background-color:rgb(212,25,32)">
<tbody>
<tr>
<td style="padding:8px 0px">
<div style="max-width:100%;margin:0px 16px;overflow:hidden">
<div style="font-weight:500;font-size:12px;overflow:hidden;text-overflow:ellipsis;text-align:left">
<a rel="nofollow" href="https://docs.oracle.com/en/java/javase/23/docs/api/java.sql/java/sql/Connection.html#abort(java.util.concurrent.Executor)" style="text-decoration:none" target="_blank"><font color="#FFFFFF" style="color:rgba(255,255,255,0.847)">Connection
(Java SE 23 & JDK 23)</font></a></div>
<div style="font-weight:400;font-size:11px;overflow:hidden;text-overflow:ellipsis;text-align:left">
<a rel="nofollow" href="https://docs.oracle.com/en/java/javase/23/docs/api/java.sql/java/sql/Connection.html#abort(java.util.concurrent.Executor)" style="text-decoration:none" target="_blank"><font color="#FFFFFF" style="color:rgba(255,255,255,0.55)">docs.oracle.com</font></a></div>
</div>
</td>
<td style="padding:6px 12px 6px 0px" width="30">
<a rel="nofollow" href="https://docs.oracle.com/en/java/javase/23/docs/api/java.sql/java/sql/Connection.html#abort(java.util.concurrent.Executor)" target="_blank"><img style="display: inline-block; width: 30px; height: 30px; border-radius: 3px;" width="30" height="30" alt="favicon.ico" src="cid:ii_196d9f1b1c0e7117bb1"></a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</a></div>
</div>
<br id="m_-224702407095609233lineBreakAtBeginningOfMessage">
<div><br>
<blockquote type="cite">
<div>On May 13, 2025, at 11:27 AM, Pavel Rappo <<a href="mailto:pavel.rappo@gmail.com" target="_blank">pavel.rappo@gmail.com</a>> wrote:</div>
<br>
<div>
<div>Is it specified how JDBC methods should react to thread interruption<br>
and concurrent closure of the connection?<br>
<br>
As a JDBC user, I'm trying to figure out my best course of action in<br>
the following scenario. A statement has been executing for a while<br>
when the application shutdown hook starts. The hook should quickly<br>
shut down everything and return.<br>
<br>
-Pavel<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote></div>