0

MS SQL データベースに接続する Java プログラムがあります。プログラムはEclipse で実行すると完全に動作しますが、AIX で実行するとエラーが発生します。

java.sql.SQLException: ネットワーク エラー IOException: リモート ホストが試行された接続操作を拒否しました。

サーバーに正常に ping を実行できますが、サーバーに telnet で接続できません。Windows デスクトップから telnet することもできません。

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.
4

2 に答える 2

2

ポート 1433 で telnet できない場合は、マシンとサーバーの間のどこかでファイアウォールによってブロックされています。これは Java 関連の問題ではありません。

「Eclipseでは完全に動作しますが、AIXでは動作しません」と言うとき、約2台の異なるコンピューターを使用している可能性がありますか? その場合、Eclipse を使用するものはファイアウォールで保護されておらず、アプリをデプロイするものはブロックされています。

繰り返しますが、Java とは何の関係もありません。TCP-IP モデルのレベル 3 エラー (TCP 層) です。

よろしく、ステファン

于 2011-08-10T16:34:51.300 に答える
0

SQL Server データベースで TCP/IP プロトコルが有効になっていない可能性があります。有効にするには:

  1. Microsoft SQL Server 2005 -> 構成ツールから、「Microsoft SQL Server 構成マネージャー」を開きます。

  2. [SQL Server 2005 ネットワーク構成] を展開し、[プロトコル] をクリックします。

  3. 「TCP/IP」を右クリックし、「有効にする」をクリックします。プロトコルのアイコンが変わり、プロトコルが有効になっていることが示されます。

SQL Server 2008 の場合:

SQL Server 2008 のネットワーク構成

于 2011-08-10T16:41:39.923 に答える