title: JDBC and Connection reset.
body: <p>I am writing resultsets to Excel using the Apache POI. The resultsets are created by via JDBC connections to SQL Server 2014. </p>
  
  <p>The calling method has the code</p>
  
  <pre><code>        ExportLargeResultSetoExcel publishQry = new ExportLargeResultSetoExcel();
          publishQry.generateExcel(rs, FILE_TO_WRITE);
  </code></pre>
  
  <p>Until yesterday, the code was working fine. But, starting today, a connection reset happens after processing a few 100 rows. If the result set has about 10 or 50 rows, the excel is being created. But, if there are 1000 rows, the connection is being reset after looping through, say, about 900 rows. I researched other posts here on stackflow, and other forums. I have SQL Server  installed on my desktop. I checked the Configuration Tool Manager settings, ports and enabled TCP/IP services as suggested in some of the postings here. However, I believe they would not have any impact because they are affecting only the local settings. I trapped the SQLServerException and it returned a SQLState of 08S01. Below is the detailed stacktrace of the exception. Is there a way I could get the connection time out programmatically? Could someone help and suggest what could be going wrong? </p>
  
  <pre><code>2016-12-25 17:03:32.791 1. ResultSet.getString(3)
  com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2399)
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2383)
  at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1884)
  at com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:6642)
  at com.microsoft.sqlserver.jdbc.TDSReader.nextPacket(IOBuffer.java:6595)
  at com.microsoft.sqlserver.jdbc.TDSReader.ensurePayload(IOBuffer.java:6571)
  at com.microsoft.sqlserver.jdbc.TDSReader.readBytes(IOBuffer.java:6864)
  at com.microsoft.sqlserver.jdbc.TDSReader.readWrappedBytes(IOBuffer.java:6886)
  at com.microsoft.sqlserver.jdbc.TDSReader.readInt(IOBuffer.java:6827)
  at com.microsoft.sqlserver.jdbc.ServerDTVImpl.getValue(dtv.java:4080)
  at com.microsoft.sqlserver.jdbc.DTV.getValue(dtv.java:226)
  at com.microsoft.sqlserver.jdbc.Column.getValue(Column.java:144)
  at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2099)
  at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2084)
  at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getString(SQLServerResultSet.java:2427)
  at net.sf.log4jdbc.ResultSetSpy.getString(ResultSetSpy.java:2413)
  at fnSampleTest.ExportLargeResultSetoExcel.generateExcel(ExportLargeResultSetoExcel.java:148)
  </code></pre>