DB connection is closed after it is idle for some time<p align=left><font face=Arial size=2></font> </p> <p>I am using MS JDBC driver 2005 1.2 and in-house written connection pooling  that was working fine for a number of years. This combination worked OK with SQLserver 2000.  But recently we switched to SQLServer 2005 (x64) on WIN Server 2003 Standard x64 eddition.  Everything seems work OK during business hours, however, after business hours when there are lesser users and connection stays idle for sometime, I am getting the following error:</p> <p align=left>com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.<br> at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)<br> at com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(Unknown Source)<br> at com.microsoft.sqlserver.jdbc.SQLServerConnection.setAutoCommit(Unknown Source)<br> at com.nms.serverframework.dbaccess.OnlineTransactionManager.freeConnection(OnlineTransactionManager.java:420)<br> at com.nms.serverframework.dbaccess.OnlineTransactionManager.releaseConnection(OnlineTransactionManager.java:707)<br> at com.nms.serverframework.dbaccess.OnlineTransactionManager.releaseConnection(OnlineTransactionManager.java:688)<br> at com.nms.serverframework.dbaccess.OnlineTransactionManager.finalize(OnlineTransactionManager.java:399)<br> at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)<br> at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)<br> at java.lang.ref.Finalizer.access$100(Finalizer.java:14)</p> <p align=left> </p> <p align=left>Any help would be appreciated</p> <p align=left> </p> <p align=left>thanks in advance</p>© 2009 Microsoft Corporation. All rights reserved.Fri, 12 Dec 2008 04:43:27 Z47d2df0a-0f32-41f8-a5b2-6d8d656d3271http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/47d2df0a-0f32-41f8-a5b2-6d8d656d3271#47d2df0a-0f32-41f8-a5b2-6d8d656d3271http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/47d2df0a-0f32-41f8-a5b2-6d8d656d3271#47d2df0a-0f32-41f8-a5b2-6d8d656d3271AllaWINhttp://social.msdn.microsoft.com/Profile/en-US/?user=AllaWINDB connection is closed after it is idle for some time<p align=left><font face=Arial size=2></font> </p> <p>I am using MS JDBC driver 2005 1.2 and in-house written connection pooling  that was working fine for a number of years. This combination worked OK with SQLserver 2000.  But recently we switched to SQLServer 2005 (x64) on WIN Server 2003 Standard x64 eddition.  Everything seems work OK during business hours, however, after business hours when there are lesser users and connection stays idle for sometime, I am getting the following error:</p> <p align=left>com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.<br> at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)<br> at com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(Unknown Source)<br> at com.microsoft.sqlserver.jdbc.SQLServerConnection.setAutoCommit(Unknown Source)<br> at com.nms.serverframework.dbaccess.OnlineTransactionManager.freeConnection(OnlineTransactionManager.java:420)<br> at com.nms.serverframework.dbaccess.OnlineTransactionManager.releaseConnection(OnlineTransactionManager.java:707)<br> at com.nms.serverframework.dbaccess.OnlineTransactionManager.releaseConnection(OnlineTransactionManager.java:688)<br> at com.nms.serverframework.dbaccess.OnlineTransactionManager.finalize(OnlineTransactionManager.java:399)<br> at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)<br> at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)<br> at java.lang.ref.Finalizer.access$100(Finalizer.java:14)</p> <p align=left> </p> <p align=left>Any help would be appreciated</p> <p align=left> </p> <p align=left>thanks in advance</p>Fri, 07 Dec 2007 15:30:30 Z2007-12-07T19:30:01Zhttp://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/47d2df0a-0f32-41f8-a5b2-6d8d656d3271#776130c4-e3be-4107-b6de-372c0253a4cehttp://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/47d2df0a-0f32-41f8-a5b2-6d8d656d3271#776130c4-e3be-4107-b6de-372c0253a4ceJohn C Gordonhttp://social.msdn.microsoft.com/Profile/en-US/?user=John%20C%20GordonDB connection is closed after it is idle for some time<p>This is most likely related to a new feature in SQL Server 2005 that enables it to poll, discover, and clean up disconnected sessions.  The first step in debugging this would be to disable the &quot;keep alive&quot; feature in SQL Server 2005 to see if it works around your issue.  If it does, then it is possible that your network card does not properly support this feature.</p> <p align=left> </p> <p align=left><a title="http://blogs.msdn.com/sql_protocols/archive/2006/03/09/546852.aspx" href="http://blogs.msdn.com/sql_protocols/archive/2006/03/09/546852.aspx">http://blogs.msdn.com/sql_protocols/archive/2006/03/09/546852.aspx</a></p> <p align=left><font face=Arial size=2></font> </p> <p><a title="http://support.microsoft.com/kb/137983" href="http://support.microsoft.com/kb/137983">http://support.microsoft.com/kb/137983</a></p> <p align=left> </p> <p align=left><u><font color="#810081"><a title="http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2435917&amp;SiteID=17" href="http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2435917&amp;SiteID=17">http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2435917&amp;SiteID=17</a></font></u></p> <p> </p> <p align=left> </p> <p align=left>Hope that helps,</p> <p align=left> </p> <p align=left>John</p>Fri, 07 Dec 2007 19:29:56 Z2007-12-07T19:30:01Zhttp://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/47d2df0a-0f32-41f8-a5b2-6d8d656d3271#dc98e040-ab14-4e0c-b1be-91e17b9453a4http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/47d2df0a-0f32-41f8-a5b2-6d8d656d3271#dc98e040-ab14-4e0c-b1be-91e17b9453a4AllaWINhttp://social.msdn.microsoft.com/Profile/en-US/?user=AllaWINDB connection is closed after it is idle for some time<p align=left><font face=Arial size=2></font> </p><span style="font-size:10pt;line-height:115%;font-family:'Arial','sans-serif'"> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:10pt;line-height:115%;font-family:'Arial','sans-serif'">I am not sure how to disable keep alive feature - on a SQL server network configuration TCP/IP property under protocol <span style=""> </span>tab it has  Enabled , but when I set it to disbled - I can not connect to a database with the JDBC driver; it also has  a number of milliseconds  - can I change it to 0 0r -1 ?.<span style="">  </span>Under the IP addresses there is an option to disable, but I think it will disable the TCP/IP connection that I need to have for the driver.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:10pt;line-height:115%;font-family:'Arial','sans-serif'">I would appreciate if you give me some steps how to do that.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><span style="font-size:10pt;line-height:115%;font-family:'Arial','sans-serif'">thanks</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"></span></p>Fri, 07 Dec 2007 20:40:05 Z2007-12-07T20:40:05Zhttp://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/47d2df0a-0f32-41f8-a5b2-6d8d656d3271#fc5c36a2-3fa1-4787-a43c-a702871e3371http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/47d2df0a-0f32-41f8-a5b2-6d8d656d3271#fc5c36a2-3fa1-4787-a43c-a702871e3371Mugunthan Mugundanhttp://social.msdn.microsoft.com/Profile/en-US/?user=Mugunthan%20MugundanDB connection is closed after it is idle for some time<p align=left><font face=Arial size=2>Keep alive is not enabled by default. So if you have not enabled it, the problem may not be keep alive. Can you get a JDBC trace log and see if it provides anymore info to troubleshoot?</font></p>Fri, 07 Dec 2007 23:17:39 Z2007-12-07T23:17:39Zhttp://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/47d2df0a-0f32-41f8-a5b2-6d8d656d3271#1472891e-5c38-4246-a4d9-73e6b6ac7de6http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/47d2df0a-0f32-41f8-a5b2-6d8d656d3271#1472891e-5c38-4246-a4d9-73e6b6ac7de6AllaWINhttp://social.msdn.microsoft.com/Profile/en-US/?user=AllaWINDB connection is closed after it is idle for some time<font face=Arial size=2> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'">The default set up had been changed. Specifically, we needed to enable the TCP/IP connectivity to access the DB via JDBC driver.</span></p> <p class=MsoNormal style="margin:0in 0in 10pt"><font face=Calibri size=3>However, the confusion is what exactly needs to be done to enable/disable<span style="">  </span>“Keep Alive” option as what had been suggested.</font></p> <p class=MsoNormal style="margin:0in 0in 10pt"><font face=Calibri size=3>The SQL Server configuration manager allows to change the TCP/IP configurations including “KEEP Alive” option <span style=""> </span>for :</font></p> <p class=MsoListParagraphCxSpFirst style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"><span style=""><span style=""><font face=Calibri size=3>1.</font><span style="font:7pt 'Times New Roman'">       </span></span></span><font face=Calibri size=3>SQL native client configurations</font></p> <p class=MsoListParagraphCxSpMiddle style="margin:0in 0in 0pt 0.5in;text-indent:-0.25in"><span style=""><span style=""><font face=Calibri size=3>2.</font><span style="font:7pt 'Times New Roman'">       </span></span></span><font face=Calibri size=3>SQL client configuration</font></p> <p class=MsoListParagraphCxSpLast style="margin:0in 0in 10pt 0.5in;text-indent:-0.25in"><span style=""><span style=""><font face=Calibri size=3>3.</font><span style="font:7pt 'Times New Roman'">       </span></span></span><font face=Calibri size=3>SQL server Network configuration</font></p> <p class=MsoNormal style="margin:0in 0in 10pt"><font face=Calibri size=3>Which one of those needs to be changed to enable access via JDBC driver?</font></p> <p class=MsoNormal style="margin:0in 0in 10pt"><font face=Calibri size=3> </font></p> <p class=MsoNormal style="margin:0in 0in 10pt"><font face=Calibri size=3>Each of the above configurations has two tabs: Protocol and IP addresses.<span style="">  </span>Right now parameter “Enabled” for both tabs have value “Yes” <span style=""> </span>for all the above configurations. <span style=""> </span>As I indicated before, when I put value “No” for parameter <span style=""> </span>Enabled under the <span style=""> </span>Protocol tab, I am not able to connect to the DB.</font></p> <p class=MsoNormal style="margin:0in 0in 10pt;tab-stops:309.0pt"><font face=Calibri size=3>I would appreciate if you would point out what parameter under what configuration is responsible for enabling/disabling the KEEP ALIVE option.</font></p> <p class=MsoNormal style="margin:0in 0in 10pt;tab-stops:309.0pt"><font face=Calibri size=3> </font></p> <p class=MsoNormal style="margin:0in 0in 10pt;tab-stops:309.0pt"><font face=Calibri size=3>thanks</font></p> <p align=left></font> </p>Fri, 04 Jan 2008 16:05:03 Z2008-01-04T16:05:03Zhttp://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/47d2df0a-0f32-41f8-a5b2-6d8d656d3271#bd5a7b58-6040-404d-9281-28a601ee0608http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/47d2df0a-0f32-41f8-a5b2-6d8d656d3271#bd5a7b58-6040-404d-9281-28a601ee0608semaj2008http://social.msdn.microsoft.com/Profile/en-US/?user=semaj2008DB connection is closed after it is idle for some time<font size=2><span style="font-family:Arial">Hi Allawin,<br><br>I'm also having similar problem after certain idle time.<br><br>com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.<br>    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)<br>    at com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(Unknown Source)<br>    at com.microsoft.sqlserver.jdbc.SQLServerConnection.rollback(Unknown Source)<br>    at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.rollback(DelegatingConnection.java:328)<br>    at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.rollback(PoolingDataSource.java:312)<br><br>Did you find any solutions?<br><br>Thanks,<br>semaj<br></span></font>Mon, 29 Sep 2008 13:24:55 Z2008-09-29T13:24:55Z