Random issue com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.

Kumar, Amit 20 Reputation points
2024-08-02T02:23:47.9233333+00:00

I am getting below issue while running jobs which are making connection with SQL server. The jobs are failing randomly with below error:

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.

at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234) ~[mssql-jdbc-8.2.2.jre8.jar!/:?]

at com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(SQLServerConnection.java:1130) ~[mssql-jdbc-8.2.2.jre8.jar!/:?]

at com.microsoft.sqlserver.jdbc.SQLServerConnection.createStatement(SQLServerConnection.java:3520) ~[mssql-jdbc-8.2.2.jre8.jar!/:?]

at com.microsoft.sqlserver.jdbc.SQLServerConnection.createStatement(SQLServerConnection.java:3179) ~[mssql-jdbc-8.2.2.jre8.jar!/:?]

Jobs are written in java and we are making JDBC call

SQL Server | Other
0 comments No comments
{count} votes

Accepted answer
  1. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2024-08-02T07:07:30.03+00:00

    Hi @Kumar,

    This is a random issue, please verify that there are no network issues causing the connection to drop. Ensuring stable network connectivity. The connection might be timing out due to inactivity. Ensure your connection pool settings are configured correctly, especially parameters like maxIdle and maxWait. In addition, if your application is sending a large number of requests, it might be hitting some resource limits. Adjusting the connection pool size and other related settings can help.

     


    If the answer is helpful,  please click "Accept Answer" and kindly upvote it.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.