You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Liquibase连接SQL Server遇TCP/IP错误,请求协助排查解决

问题背景

Liquibase配置文件

driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
classpath: ..\\Program Files\\sqljdbc_12.6\\enu\\jars\\mssql-jdbc-12.6.0.jre11.jar
changeLogFile: D:\\Liquibase\\databaseChangeLog\\dbchangelog.sql
url: jdbc:sqlserver://<SHIVAM-LAPTOP>:1433;databaseName=liquibase;integratedSecurity=true;encrypt=false;

Java版本

C:\Users\shiva>java -version
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

执行命令

c:\\Liquibase>liquibase --defaultsFile="C:\\Liquibase\\liquibase.properties" update

错误信息

Starting Liquibase at 11:57:02 (version 4.25.1 #690 built at 2023-12-18 16:29+0000)
Liquibase Version: 4.25.1
Liquibase Open Source 4.25.1 by Liquibase
ERROR: Exception Details
ERROR: Exception Primary Class:  SQLServerException
ERROR: Exception Primary Reason: The TCP/IP connection to the host <SHIVAM-LAPTOP>, port 1433 has failed. Error: "<SHIVAM-LAPTOP>. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
ERROR: Exception Primary Source: 4.25.1

Unexpected error running Liquibase: Connection could not be created to jdbc:sqlserver://<SHIVAM-LAPTOP>:1433;databaseName=liquibase;integratedSecurity=true;encrypt=false; with driver com.microsoft.sqlserver.jdbc.SQLServerDriver.  The TCP/IP connection to the host <SHIVAM-LAPTOP>, port 1433 has failed. Error: "<SHIVAM-LAPTOP>. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

For more information, please use the --log-level flag

排查与解决步骤
  • 匹配JDBC驱动与Java版本:你用的mssql-jdbc-12.6.0.jre11.jar仅支持JRE 11+,但当前Java是JDK 1.8,需替换为适配JRE 8的驱动(比如mssql-jdbc-9.4.1.jre8.jar),并同步更新配置文件中的classpath路径。
  • 确认SQL Server服务运行状态:打开services.msc,检查SQL Server (MSSQLSERVER)或对应实例服务是否处于运行状态;若为命名实例,需修改JDBC URL为jdbc:sqlserver://<SHIVAM-LAPTOP>\<实例名>;databaseName=liquibase;...,并确认实例使用的端口。
  • 启用SQL Server TCP/IP协议:打开SQL Server配置管理器,展开SQL Server网络配置→对应实例的协议,右键启用TCP/IP;双击TCP/IP进入IP地址标签,在IPAll中确认TCP端口为1433(或实际使用端口),之后重启SQL Server服务。
  • 测试主机名解析:在命令行执行ping <SHIVAM-LAPTOP>,若解析失败,将URL中的主机名替换为localhost或本地IP地址(如127.0.0.1)重试。
  • 检查防火墙拦截:临时关闭Windows防火墙测试连接,若恢复则添加1433端口的TCP入站规则;同时排查第三方安全软件是否拦截该端口。
  • 配置Windows身份认证依赖:确保运行Liquibase的用户有SQL Server访问权限,且SQL Server已启用SQL Server和Windows身份验证模式;另外,JRE 8需将JDBC驱动包中auth\x64(64位系统)下的sqljdbc_auth.dll放入C:\Windows\System32,或把该目录加入系统PATH。

内容的提问来源于stack exchange,提问作者shivam yadav

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 08:25:16