Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过telnet连接到外部数据库_Java_Unix_Telnet_Jtds - Fatal编程技术网

Java 通过telnet连接到外部数据库

Java 通过telnet连接到外部数据库,java,unix,telnet,jtds,Java,Unix,Telnet,Jtds,我有一个连接到MS SQL数据库的java程序。该程序在eclipse中运行时运行得非常好,但是在AIX中运行时出现了一个错误: java.sql.SQLException:网络错误IOException:远程主机拒绝尝试的连接操作 我可以成功ping服务器,但无法远程登录服务器。我也无法从windows桌面远程登录 我正在使用jtds连接: String connectionString = "jdbc:jtds:sqlserver://"+dropez_ip_address+"/"+drop

我有一个连接到MS SQL数据库的java程序。该程序在eclipse中运行时运行得非常好,但是在AIX中运行时出现了一个错误:

java.sql.SQLException:网络错误IOException:远程主机拒绝尝试的连接操作

我可以成功ping服务器,但无法远程登录服务器。我也无法从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”时,你用的是两台不同的计算机?如果是这样,则使用eclipse的应用程序不会被防火墙拦截,而部署应用程序的应用程序会被阻止

但同样,与java无关。这是TCP-IP模型的3级错误(TCP层)

问候,,
Stéphane

您的SQL Server数据库可能没有启用TCP/IP协议,要启用它:

  • 从Microsoft SQL Server 2005->配置工具中,打开“Microsoft SQL Server配置管理器”

  • 展开“SQL Server 2005网络配置”,然后单击“协议”

  • 右键单击“TCP/IP”,然后单击“启用”。协议图标将更改,以显示协议已启用

  • 对于SQL Server 2008:


    您所说的“我可以成功ping服务器,但无法远程登录到服务器。我也无法从windows桌面远程登录”是什么意思?您的意思是没有安装远程登录,或者您没有使用它的权限,或者您尝试在那里远程登录,但什么也没有发生(或发生了什么事情)。远程登录与此无关。您没有通过telnet连接到数据库。您的数据库服务器不允许从应用程序连接SQL server端口(1433);这可能是网络配置或防火墙配置问题,而不是软件问题。是的,程序在我的桌面上运行时运行,但在AIX服务器上运行时不会运行。因此,AIX服务器上可能有防火墙阻止telnet端口上的传出连接,或者网络上其他地方的规则。我正在使用SQL Server 2008,当我打开SQL Server Configuration Manager时,我发现数据库位于“SQL Native Client 10.0配置->别名”下,协议是“tcp”,我没有机会更改它。@Mike我添加了一个屏幕截图,用于在SQL Server 2008中检查它。我没有这些选项,可能是因为数据库不是我的,而是由托管服务提供的?@Mike如果您的数据库在托管服务中,并且您的桌面连接到远程托管服务,那么它肯定与AIX防火墙配置有关,您需要启用1433端口出站流量。托管服务是否允许来自任何IP的连接,或者它们必须允许某些IP?也检查一下。托管服务说这也是防火墙,我会进一步调查,谢谢你的帮助!