Connection Exception Using Spring JDBC Template

I have a simple web application developed using Spring, and recently I have been having some problems connecting to the database. My database is on MS SQL Server 2005.

To extract the data, I implemented several DAOs using the JDBCTemplate class provided by the framework.

Sometimes I get this exception:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.DataAccessResourceFailureException: StatementCallback; SQL [SELECT [Campaigns].[CampaignID],[CampaignCode],[CampaignType],[StartDate],[EndDate],[Status],[FirstUpdate],[LastUpdate],[FirstUpdateUserID],[LastUpdateUserID],[CampaignDescriptions].[Description] FROM [Campaigns] INNER JOIN [CampaignDescriptions] ON [Campaigns].[CampaignID] = [CampaignDescriptions].[CampaignID] ORDER BY [StartDate] DESC]; Connection reset by peer: socket write error; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset by peer: socket write error org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 

an exception occurs only when the requested request is executed.

I can not understand what causes this problem. Any idea?

Request Execution Method:

 @Transactional(propagation = Propagation.NEVER) public Campaign[] getAll() { List<Campaign> campList = getJdbcTemplate() .query(BASE_QUERY, new CampaignMapper()); return campList.toArray(new Campaign[0]); } 

where BASE_QUERY matches the exception message.

+4
source share
1 answer

it looks like a legacy communication problem. It can only be displayed in this query if it is fairly common or the first is executed (most of the time).

What you need to check:

  • Server connection timeout
  • Connection Pool Connection Timeout
  • Connection pool checks connection before use
+3
source

Source: https://habr.com/ru/post/1447442/


All Articles