我試圖添加服務器作爲SQL Server故障轉移,並且它未使用端口1443
,我正在使用端口2776
。我試圖指定它,但我試過的一切都沒有工作。我怎麼能這樣做?如何指定SQL Server中故障轉移合作伙伴服務器的JDBC連接URL中的端口
private String url = "jdbc:sqlserver://server1:2776;DatabaseName=db;failoverPartner=server2";
我試過以下配置,但沒有一個工作。
...failoverPartner=server2:2776
...failoverPartner=server2,2776
...failoverPartner=server2\\db
但每次我得到異常。
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host server2, port 1433 has failed. Error: "connect timed out. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host server2:2776, port 1433 has failed. Error: "null. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host server2, 2776, port 1433 has failed. Error: "null. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".
我添加了標籤'failover'和'database-mirroring',因爲我認爲這就是您正在處理的內容...正確嗎? –
[這個答案](http://stackoverflow.com/a/12378514/243373)能幫助你嗎?不是一個完全相同的問題,但它可能與'failoverPartner'名稱中缺少的實例名稱有關。 –
另外,你讀過這個鏈接:[使用數據庫鏡像(JDBC)](https://msdn.microsoft.com/en-us/library/aa342332(v = sql.110).aspx)?也許這裏有一些指針? –