如何通过jdbc连接SQL Server Express版本

shi_hang_nk shi_hang_nk 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
大家好,我需要用JDBC连接SQL Server 2012 Express版本。现在我用SQL Server Management Studio连接都没有问题,但是用

String connectionUrl = "jdbc:sqlserver://localhost;databaseName=MyDB;integratedSecurity=true;";
Connection conn = DriverManager.getConnection(connectionUrl);

报出异常
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. 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.".

因为我用的是 SQL Server Express 版本,所以不知道如何配置端口。请教解决过这个问题的高手。
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
shi_hang_nk
MS-SQL Server 34,876 成员 254,635 内容