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

shi_hang_nk 2013-05-17 12:20:18
大家好,我需要用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 版本,所以不知道如何配置端口。请教解决过这个问题的高手。
...全文
209 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
KevinLiu 2013-05-17
  • 打赏
  • 举报
回复
在配置管理器中配置端口,如果是2005的话还要再外围配置管理器开启远程连接。
daiyueqiang2045 2013-05-17
  • 打赏
  • 举报
回复
lz确保 1:开启远程连接 2:开启tcp/ip 3:确定防火墙是否开始1433端口(如果你没有修改数据库默认端口的话)

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧