SQL Server JDBC driver can't detect lost connection quickly
<p>I'm using JDBC Driver <code>sqlserver-jdbc-4.0.jar</code> to connect to SQL Server. I created a connection and used it successfully. </p>

<p>Then I turned off the network interface of the SQL Server machine. When I run the next command, the JDBC driver on the side of my application requires about 15 minutes to understand that the connection is lost. I tried several things:</p>

<ol>
<li>configured JDBC driver properties <code>LoginTimeout=5, LockTimeout=5, QueryTimeout=5</code> (5 seconds)</li>
<li>called <code>Statement.setQueryTimeout()</code> to set timeout to 5 seconds</li>
<li>called <code>Connection.isValid()</code> with 5 seconds timeout - it also stuck for 15 minutes</li>
</ol>

<p>Another possible option - <code>Connection.setNetworkTimeout()</code> but it is not implemented by the SQL Server driver. I also can not reach the socket used by the JDBC driver to set up TCP Keepalive on it.</p>

<p>If I close the connection and then open it again, it immediately understands that SQL Server instance is unreachable. </p>

<p>How can I overcome my problem and detect lost connection within several seconds instead of 15 minutes? </p>