您的位置:首页技术文章
文章详情页

错误:到主机的TCP / IP连接失败。java.net.ConnectException:连接被拒绝:connect

【字号: 日期:2024-04-28 09:13:45浏览:29作者:猪猪
导读:如何解决错误:到主机的TCP / IP连接失败。java.net.ConnectException:连接被拒绝:connect?我按照以下步骤使用JDBC成功连接到sqlExpress实例:使用sql Express配置TCP / IP通信 打开sql Server配置管理器。转到sql Serve...
如何解决错误:到主机的TCP / IP连接失败。java.net.ConnectException:连接被拒绝:connect?

我按照以下步骤使用JDBC成功连接到sqlExpress实例:

使用sql Express配置TCP / IP通信 打开sql Server配置管理器。转到sql Server网络配置-> sqlEXPRESS的协议将TCP / IP协议的状态设置为“已启用”(如果尚未启用)。打开“ TCP / IP的属性”窗口,转到“ IP地址”部分。转到此属性页面的底部,并将“ TCP端口”设置IPAll为1433。使用以下方法连接到sqlExpress实例 Microsoft’s JDBC driver for sql ServerJDBC URL: jdbc:sqlserver://localhost;instance=sqlEXPRESS;databaseName=<your DB>;user=<your User>;password=<your Passwd>解决方法

我在用

Windows 7的 Netbeans IDE 7.1.2 SQL Server管理Studio Express 2005 JDK1.6

连接到数据库时出现以下错误:

com.microsoft.sqlserver.jdbc.SQLServerException:与主机的TCP /IP连接失败。java.net.ConnectException:连接被拒绝:connect

我的连接字符串是:

Class.forName('com.microsoft.sqlserver.jdbc.SQLServerDriver'); Connection connection = DriverManager.getConnection( 'jdbc:sqlserver://127.0.0.1:1433;databaseName=dbcm;' + 'user=sa;password=sa');

我检查了以下内容:

在SQL Server配置管理器中,SQLEXPRESS的协议:启用了TCP / IP实际上,我也启用了剩余的3个。 SQL Server(SQLExpress)和SQL Browser Service都在运行。
标签: java
相关文章: