1

I was getting Socket closed exception, case and reason is refer from : Getting SQLServerException socket close for one particular method in Java

So to resolve this I have used(JdbcInterceptors) as per the suggestion : WebApp (Tomcat-jdbc) Pooled DB connection throwing abandon exception

Thank you guys, but this solution is not working in my case, Still, I am getting Socket Closed exception, I have used jdbcInterceptors and you can check below configuration...

<Resource
    name="jdbc/dev"
    auth="Container"
    type="javax.sql.DataSource"
    maxActive="100"
    maxIdle="5"
    maxWait="-1"
    driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
    url="jdbc:sqlserver://Localhost:1433;DatabaseName=outingDB"
    username="sa"
    password="local#123"
    removeAbandoned="true"
    removeAbandonedTimeout="30"
    logAbandoned="false"
    abandonWhenPercentageFull="50"
jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer"/>

In My case, One of my sql query taking more execution time then removeAbandonedTimeout, So the Connection is getting closed and it throws as Socket Closed exception.

Now I want to reset Abandoned Timer, if connection is in use or is there is another way to increase Socket timeout for database.

Please give me suggestions, if it is right or wrong or is there another way to achieve this?, thank you in advance.

R. Ingle
  • 41
  • 2
  • 7

1 Answers1

2

According to the documentation, the removeAbandonedTimeout value should be set to the longest running query your applications might have. So measure the time it takes to execute your longest query and increase the value int this parameter.

Source: https://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Common_Attributes

Roque Santos
  • 225
  • 2
  • 9