JAVA SQLServerException: 通過埠 1433 連線到主機 127.0.0.1 的 TCP/IP 連線失敗
阿新 • • 發佈:2021-01-15
[2021-01-15 13:20:14.623] ERROR [Druid-ConnectionPool-Create-497208183] DruidDataSource.java:2471 - create connection SQLException, url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test, errorCode 0, state 08S01 com.microsoft.sqlserver.jdbc.SQLServerException: 通過埠 1433 連線到主機 127.0.0.1 的 TCP/IP 連線失敗。錯誤:“Connection refused: connect。請驗證連線屬性。確保 SQL Server 的例項正在主機上執行,且在此埠接受 TCP/IP 連線,還要確保防火牆沒有阻止到此埠的 TCP 連線。”。 at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234) at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:285) at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2434) at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:659) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2546) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2216) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2067) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1204) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:825) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1558) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1623) at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2468)
啟用 NamedPipes、TCP/IP,如果不行,重啟下 SQL Server 服務