好了,所以我有这样的代码:的Java连接到SQL Server
package com.andrewxd.banksystem;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class Interface
{
public static void main(String[] args)
{
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1443;user=Andrew;password=andrei23;database=BankSystem");
System.out.println("test");
Statement sta = conn.createStatement();
String Sql = "select * from Clients";
ResultSet rs = sta.executeQuery(Sql);
System.out.println(rs.next());
} catch (Exception e){
e.printStackTrace();
}
}
}
,但它给了我这个错误可以有人帮助我?:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1443 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.".
我试图寻找,但我没有”真的很了解。
从我的理解端口是不正确的,但我如何找到正确的IP /端口?
从我的理解端口是不正确的,但我如何找到正确的IP /端口? –
如果您有多个网络接口,请尝试使用这些IP地址。 – RaviH
这应该是在你的问题,否则它可以被错过。 – Batty