Forum Discussion

KevinWang2014's avatar
KevinWang2014
Copper Contributor
Aug 08, 2022
Solved

Cannot connect to SQL 2022 Preview at Windows Server 2022 Standard by JDBC driver(TCP, 1433)

It works:

1. Win2019/2016 + SQL 2022

2. Win2022 + SQL 2019

 

It does not work:

1. Win2022 + SQL 2022

 

From wireshark it looked like not a Firewall issue.

netstat is showing: TCP 0.0.0.0:1433 WIN-392VVL443C0:0 LISTENING

JDBC URL: jdbc:sqlserver://WIN-392VVL443C0:1433;integratedSecurity=false

User Name: sa which is enabled

 

If I use cmd: SQLCMD.EXE -U sa -P XXX, it worked.

 

Exception when used JDBC driver by user name and password:

####

Aug 8, 2022 10:24:20 PM STDOUT: readJdbcParameters >> jdbcDriverClass: com.microsoft.sqlserver.jdbc.SQLServerDriver
Aug 8, 2022 10:24:20 PM STDOUT: DatabaseUtilities> initDataSource>> jdbcDriverClass: com.microsoft.sqlserver.jdbc.SQLServerDriver
Aug 8, 2022 10:25:53 PM LoggerUtilities STDERR: Exception:
com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientConnectionId:0f82270f-45fa-4aa6-8878-0b38c3e8195c
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:3151)
at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:2062)
at com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:6596)
at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:7762)
at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:7725)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:5232)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3988)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3932)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7375)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3206)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2713)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2362)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2213)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1276)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:861)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
at com.xxxx.scm.server.db.util.DBConnectionProxy.getConnectionFromDriverManager(DBConnectionProxy.java:414)
at com.xxxx.scm.server.db.util.MSJDBCDriver.getConnection(MSJDBCDriver.java:182)
at com.xxxx.scm.server.db.util.JDBCDriver.getDatabaseConnectionWithNTLMv2Retry(JDBCDriver.java:192)
at com.xxxx.scm.server.db.util.DatabaseUtilities.getDatabaseConnectionWithNTLMv2Retry(DatabaseUtilities.java:606)
at com.xxxx.scm.server.db.util.DatabaseUtilities.getDatabaseConnectionWithNTLMv2Retry(DatabaseUtilities.java:585)
at com.xxxx.scm.server.db.util.DbUtil.getDatabaseConnectionWithTlsCheck(DbUtil.java:2278)
at com.xxxx.scm.install.ui.SqlPropPanel.checkDBConnection(SqlPropPanel.java:2254)
at com.xxxx.scm.install.ui.SqlPropPanel.btnLoadPath_actionPerformed(SqlPropPanel.java:1875)
at com.xxxx.scm.install.ui.SqlPropPanel.lambda$jbInit$0(SqlPropPanel.java:416)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6635)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
at java.desktop/java.awt.Component.processEvent(Component.java:6400)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.net.SocketException: Connection reset
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:186)
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:2054)
... 59 more

 

  • David-Engel's avatar
    David-Engel
    Steel Contributor

    As a workaround until it's fixed, try disabling TLS 1.3. Either in the server OS' registry
    https://docs.microsoft.com/en-us/windows-server/security/tls/tls-registry-settings#tls-dtls-and-ssl-protocol-version-settings

    Or just in SQL Server by setting the global trace flag 11808. The trace flag will be effective only after service restart. So it’s better to specify it when the service starts with the switch -T11808. It will need to be set using SQL Server Configuration Manager so that it is applied on startup.

    https://www.red-gate.com/simple-talk/databases/sql-server/learn/how-to-enable-sql-server-trace-flags/

     

    • cn's avatar
      cn
      Copper Contributor
      Thanks this fix worked for me as well!
    • KevinWang2014's avatar
      KevinWang2014
      Copper Contributor
      Hi David-Engel,

      Thanks for your help in figuring out its TLS compatibility issues. It's working now after I disabled TLS1.3 from OS registry.

      I also tried DBCC TRACEON (11808, -1), that workaround did not work no matter if service was rebooted. Once it was rebooted DBCC TRACESTATUS was back to 0.

      I believe Microsoft will resolve this before SQL Server 2022 is officially released. It's not good to ask customers to use workarounds. If it could not be resolved before it's officially released we have to document it and let customers to take the risks and use the workaround if they have to use SQL Server 2022.
      • David-Engel's avatar
        David-Engel
        Steel Contributor
        You would need to enable the trace flag as a startup parameter using SQL Server Configuration Manager. Just running DBCC TRACEON won't work. (Edited my previous reply to be more specific.)

        Yes, the issue is/will be resolved in the next release (RC0).
  • cn's avatar
    cn
    Copper Contributor

    KevinWang2014 , I am having this exact same problem. I've just upgraded to CTP 2.1 in the hope that it would make a difference, bad sadly it didn't.

     

    Did you end up solving the issue?

    • KevinWang2014's avatar
      KevinWang2014
      Copper Contributor

      cn 

       

      Yes, I also tested 2.1 and saw same problem. It should be a SQL Server bug. We have filled a defect to Microsoft by our company, I would let you know once we get feedback.

Resources