簡體   English   中英

通過 telnet 連接到外部數據庫

[英]Connecting to external database through telnet

我有一個連接到 MS SQL 數據庫的 java 程序。 該程序在通過eclipse運行時運行良好,但是當我通過 AIX 運行它時出現錯誤:

java.sql.SQLException:網絡錯誤 IOException:遠程主機拒絕嘗試連接操作。

我可以成功 ping 服務器,但無法 telnet 進入服務器。 我也無法從我的 windows 桌面遠程登錄。

我正在使用 jtds 連接:

String connectionString = "jdbc:jtds:sqlserver://"+dropez_ip_address+"/"+dropez_db_name;
ResultSet rs = null;
Statement stmt = null;

try{

    Class.forName("net.sourceforge.jtds.jdbc.Driver");
    Connection conn = DriverManager.getConnection(connectionString, dropez_db_username, dropez_db_password);

    stmt = conn.createStatement();
}catch(Exception e){}

這是 jTDS 中有關該問題的一些文檔,但我仍然無法解決該問題。

Why do I get java.sql.SQLException: "Network error IOException: Connection refused: connect" when trying to get a connection?

The "Connection refused" exception is thrown by jTDS when it is unable to connect to the server. There may be a number of reasons why this could happen:

    - The server name is misspelled or the port number is incorrect.
    - SQL Server is not configured to use TCP/IP. Either enable TCP/IP from SQL Server's Network Utility app or have jTDS connect via named pipes (see the URL format for information on how to do this).
    - There is a firewall blocking port 1433 on the server.

To check whether TCP/IP is enabled and the port is not blocked you can use "telnet 1433". Until telnet doesn't connect, jTDS won't either. If you can't figure out why, ask your network administrator for help.

如果您無法在端口 1433 上進行 telnet,則您的計算機和服務器之間的某處被防火牆阻止了。 這不是與 java 相關的問題。

可能是當您說“它在 eclipse 但不是 AIX 下完美運行”時,您正在使用大約 2 台不同的計算機? 如果是這樣,則帶有 eclipse 的那個沒有防火牆,您部署應用程序的那個被阻止。

但同樣,與 java 無關。 這是 TCP-IP model 的 3 級錯誤(TCP 層)。

問候, 斯蒂芬

您的 SQL 服務器數據庫可能沒有啟用 TCP/IP 協議,要啟用它:

  1. 從 Microsoft SQL 服務器 2005 -> 配置工具,打開“Microsoft SQL 服務器配置管理器”。

  2. 展開“SQL Server 2005 網絡配置”,然后單擊“協議”。

  3. 右鍵單擊“TCP/IP”,然后單擊“啟用”。 該協議的圖標將更改以顯示該協議已啟用。

對於 SQL 服務器 2008:

SQL Server 2008 網絡配置

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM