Microsoft driver does not time out during connection validation using JDBC4ValidConnectionChecker in JBoss EAP

Solution Unverified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7
  • Microsoft SQL Server JDBC Driver

Issue

  • Observing hangs during connection validation (of externally terminated connections) when using the JDBC4ValidConnectionChecker validation class.

  • A series of thread dumps collected over a minute or more show the same (unchanging) stack trace:

    java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0(Native Method)
        ...
        at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7417)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3488)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:262)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:237)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQueryInternal(SQLServerStatement.java:722)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.isValid(SQLServerConnection.java:6122)
        at org.jboss.jca.adapters.jdbc.extensions.novendor.JDBC4ValidConnectionChecker.isValidConnection(JDBC4ValidConnectionChecker.java:58)
        at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnectionFactory.isValidConnection(BaseWrapperManagedConnectionFactory.java:1285)
    

Resolution

Contact Microsoft Support for specific recommendations.

As per Content from github.com is not included.this bug report, Microsoft advised using socketTimeout parameter in the connection url to avoid the hang, e.g.:

jdbc:sqlserver://<DBSERVER>;databaseName=<DBNAME>;instanceName=<INSTANCE_NAME>;socketTimeout=20

Root Cause

Disclaimer: Links contained herein to external website(s) are provided for convenience only. Red Hat has not reviewed the links and is not responsible for the content or its availability. The inclusion of any link to an external website does not imply endorsement by Red Hat of the website or their entities, products or services. You agree that Red Hat is not responsible or liable for any loss or expenses that may result due to your use of (or reliance on) the external site or content.

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.