好了,所以我有這樣的代碼:的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