Related Documents
Document Properties
Kbid
30134T
Last Modified
31-May-2022
Added to KB
24-Feb-2022
Public Access
Everyone
Status
Online
Doc Type
Guidelines, Concepts & Cookbooks
Product
ICM 7.10

Guide - 7.10.20+ Avoid MSSQL Reconnect Issues

Table of Contents


Product Version

7.10

Product To Version


Status

1 Introduction

Most reconnection issues with the MSSQL Database are caused by too many TCP connections to the database. The SQL server has no free ports during the connection setup phase. The error looks like

The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption.


The follow changes can reduce the number of failed connection setups for the application code:

  1. Enable reconnect in case of a failure
  2. Reduce the number of new connections by configuring (optimizing) the JDBC-connection pool

2 Enable Reconnect

Since version 9.4.0 the JDBC driver contains an additional parameter for reconnect.

The mssql-jdbc driver is updated in all LTS versions of ICM. To improve the rollout speed of the change, the project can apply a version filter to update the library without updating the whole project. Please keep in mind to remove the "patch" after migrating to the latest LTS version.

LibraryOld VersionNew Version

com.microsoft.sqlserver:mssql-jdbc

8.4.1.jre89.4.0.jre8

Following adaptions are recommended:

PropertyDefaultValue
connectRetryCount13
connectRetryInterval1020
loginTimeout1530

See the documentation of the jdbc-driver to configure the reconnect capability.

2.1 How to get the used version

All libraries are listed at <IS_SHARE>/ivy.xml. The line can be found easily.

cat ivy.xml | grep "mssql-jdbc"


<dependency org="com.microsoft.sqlserver" name="mssql-jdbc" rev="9.4.0.jre8" conf="development-cartridges, production-cartridges, test-cartridges" transitive="false"/>

2.2 Availability in ICM versions

ICMmssql-jdbc

7.10.26.19-LTS

9.4.0.jre8
7.10.32.9-LTS9.4.0.jre8
7.10.37.09.4.0.jre8
7.10.38.3-LTS9.4.0.jre8

2.3 Version Provider

In case the project can't update to an newer ICM soon. The version can be defined at project too. The project can declare a specific filter for project-specific dependencies, please add this section to the build.gradle of the customization. The build.gradle can contain the following block:

build.gradle
versionRecommendation {
    provider {
        // thirdparty.version to resolve version conflicts of custom cartridges
        properties('thirdparty', file('thirdparty.version')) {}
    }
}

Afterwards versions can be adapted in the Java-like property file:

thirdparty.version
com.microsoft.sqlserver:mssql-jdbc=9.4.1.jre8

The documented version of the JDBC driver could be updated meanwhile. See https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc. Keep in mind that the version needs to have a JRE8 extension.

3 Configuration JDBC Connection Pool

ICM uses an Apache connection pool which has 3 important configurations:


Descriptionoldnew
intershop.jdbc.mssql.dbcp.pool.MaxIdleIn case the pool has more than this amount of idle connections, the pool will automatically close connections, which are "closed" by the application.516
intershop.jdbc.mssql.dbcp.pool.MinIdleIn case the pool has less than this amount of idle connections, the pool will automatically create new connections without an explicit connection request54
intershop.jdbc.mssql.dbcp.pool.MaxTotalMax amount of connections handle by the pool150150

The value of MaxIdle should be significant larger than MinIdle, so that used connections can be stored in the pool without closing them. The MinIdle value can be increased in case the application needs very fast a larger amount of connections.

Disclaimer

The information provided in the Knowledge Base may not be applicable to all systems and situations. Intershop Communications will not be liable to any party for any direct or indirect damages resulting from the use of the Customer Support section of the Intershop Corporate Web site, including, without limitation, any lost profits, business interruption, loss of programs or other data on your information handling system.

Customer Support
Knowledge Base
Product Resources
Tickets