简体   繁体   English

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

[英]Error:The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect

I am using 我在用

  • Windows 7 Windows 7的
  • Netbeans IDE 7.1.2 Netbeans IDE 7.1.2
  • SQL Server Management Studio Express 2005 SQL Server Management Studio Express 2005
  • JDK1.6 JDK1.6

I am getting the below error while connecting to the database: 连接到数据库时出现以下错误:

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. com.microsoft.sqlserver.jdbc.SQLServerException:与主机的TCP / IP连接失败。 java.net.ConnectException: Connection refused: connect java.net.ConnectException:连接被拒绝:连接

My connection string is: 我的连接字符串是:

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

I've checked below things: 我检查了下面的事情:

  1. In SQL Server Configuration Manager, Protocols for SQLEXPRESS : TCP/IP Enabled In fact I made enable remaining 3 too. 在SQL Server配置管理器中,SQLEXPRESS的协议:TCP / IP已启用实际上我也使启用了3。
  2. SQL Server(SQLExpress) and SQL Browser Service both are running. SQL Server(SQLExpress)和SQL Browser Service都在运行。

I followed the steps below to successfully connect to an SQLExpress instance using JDBC: 我按照以下步骤使用JDBC成功连接到SQLExpress实例:

  1. Configure TCP/IP communication with SQL Express 使用SQL Express配置TCP / IP通信
    1. Open SQL Server Configuration Manager. 打开SQL Server配置管理器。
    2. Go to SQL Server Network Configuration -> Protocols for SQLEXPRESS 转到SQL Server网络配置 - > SQLEXPRESS的协议
    3. Set the status of TCP/IP protocol to "Enabled" (if it is already not). 将TCP / IP协议的状态设置为“已启用”(如果已经没有)。
    4. Open Properties window for TCP/IP, go to IP Addresses section. 打开TCP / IP的“属性”窗口,转到“IP地址”部分。
    5. Go to the bottom of this property page and set the TCP Port under IPAll to 1433. 转到此属性页的底部,将IPAll下的TCP端口设置为1433。
  2. Connect to the SQLExpress instance using Microsoft's JDBC driver for SQL Server 使用Microsoft's JDBC driver for SQL Server连接到SQLExpress实例
    1. JDBC URL: jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=<your DB>;user=<your User>;password=<your Passwd> JDBC URL: jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=<your DB>;user=<your User>;password=<your Passwd>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.net.ConnectException:连接被拒绝的TCP - java.net.ConnectException: Connection refused TCP Java Mail错误:java.net.ConnectException:连接被拒绝:connect - Java Mail Error : java.net.ConnectException: Connection refused: connect java.net.ConnectException:连接被拒绝:client / server tcp socket中的connect ,, error - java.net.ConnectException: Connection refused: connect ,,error in client /server tcp socket Eclipse 4.23.0 连接拒绝主机:localhost; 嵌套异常是:java.net.ConnectException:连接被拒绝:连接 - Eclipse 4.23.0 Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection refused: connect 与主机的TCP / IP连接失败。 java.net.BindException:已在使用的地址:connect Driver - The TCP/IP connection to the host has failed. java.net.BindException: Address already in use: connect Driver RMI服务器连接拒绝托管:#############; 嵌套的异常是:java.net.ConnectException:连接被拒绝:connect - RMI Server Connection refused to host: ############ ; nested exception is: java.net.ConnectException: Connection refused: connect 数据库错误:与主机的TCP / IP连接失败。 java.net.BindException:地址已在使用中:connect - database error : The TCP/IP connection to the host has failed. java.net.BindException: Address already in use: connect 连接异常java.net.ConnectException上从主机到HDFS的调用失败:连接被拒绝 - call from host to HDFS failed on connection exception java.net.ConnectException: Connection refused 来电 <hostname> / <ip> 至 <hostname> :9000连接异常失败:java.net.ConnectException:连接被拒绝 - Call From <hostname>/<ip> to <hostname>:9000 failed on connection exception: java.net.ConnectException: Connection refused java.net.ConnectException:无法连接到 localhost/127.0.0.1(端口 80):连接失败:ECONNREFUSED(连接被拒绝) - java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 80): connect failed: ECONNREFUSED (Connection refused)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM