[英]Error:The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect
I am using 我在用
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: 我检查了下面的事情:
I followed the steps below to successfully connect to an SQLExpress instance using JDBC: 我按照以下步骤使用JDBC成功连接到SQLExpress实例:
IPAll
to 1433. IPAll
下的TCP端口设置为1433。 Microsoft's JDBC driver for SQL Server
Microsoft's JDBC driver for SQL Server
连接到SQLExpress实例
jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=<your DB>;user=<your User>;password=<your Passwd>
jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=<your DB>;user=<your User>;password=<your Passwd>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.