title: How to resolve DataAccessResourceFailureException in a Batch Job?
body: <p>I have a batch job which runs twice and once in a while I get <code>org.springframework.dao.DataAccessResourceFailureException: StatementCallback</code>. I did some analysis and I found out that it is not a Database issue. This happens when JDBC is not able to connect to database. I don't see this exception everyday. I am not sure what else do I need to check? </p>
  
  <p>I get the DB connection from the properties file using Spring JDBC template.</p>
  
  <p><code>jdbc.source.url=jdbc:sqlserver://dbServer:1433;DatabaseName=dbname
  jdbc.source.username=userName
  jdbc.source.password=pass!</code></p>
  
  <p>Stack trace:</p>
  
  <pre><code>Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2400) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2384) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1884) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:6642) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.TDSReader.nextPacket(IOBuffer.java:6595) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.TDSReader.ensurePayload(IOBuffer.java:6571) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.TDSReader.readBytes(IOBuffer.java:6864) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.TDSReader.readWrappedBytes(IOBuffer.java:6886) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.TDSReader.readInt(IOBuffer.java:6827) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.TDSReader.readUnsignedInt(IOBuffer.java:6844) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.PLPInputStream.readBytesInternal(PLPInputStream.java:313) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.PLPInputStream.getBytes(PLPInputStream.java:129) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.DDC.convertStreamToObject(DDC.java:616) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.ServerDTVImpl.getValue(dtv.java:4030) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.DTV.getValue(dtv.java:226) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.Column.getValue(Column.java:144) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2099) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2084) ~[sqljdbc42.jar:?]
  at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getString(SQLServerResultSet.java:2441) ~[sqljdbc42.jar:?]
  at com.mercuryinsurance.r3.migration.dao.DataMigrationDaoDailyImpl.lambda$16(DataMigrationDaoDailyImpl.java:329) ~[migration.jar:?]
  at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93) ~[spring-jdbc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
  at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60) ~[spring-jdbc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
  at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:455) ~[spring-jdbc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
  at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:400) ~[spring-jdbc-4.0.0.RELEASE.jar:4.0.0.RELEASE]
  </code></pre>