简体   繁体   English

到主机server.com/Db_name的TCP / IP连接,端口1433失败

[英]The TCP/IP connection to host server.com/Db_name, port 1433 has failed

The question might be a basic one and if it is, pardon me. 这个问题可能是一个基本的问题,如果是,请原谅。 I'm trying to connect my Android app to MSSQL Server . 我正在尝试将我的Android应用程序连接到MSSQL Server I used the same code in my question in the link below. 我在下面的链接中的问题中使用了相同的代码。 I have used sqljdbc 4.3.0 according to the chosen answer in this link: 我根据此链接中选择的答案使用了sqljdbc 4.3.0:

com.mysql.jdbc.driver class not found exception com.mysql.jdbc.driver类未找到异常

When I did this It debugs successfully but when I run it on my device which is Samsung Galaxy Y (Gingerbread) it gives me this error: 当我这样做时,它将成功调试,但是当我在三星Galaxy Y(姜饼)的设备上运行它时,会出现以下错误:

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host server.com/Db_name, 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.".

Any help would be highly appreciated. 任何帮助将不胜感激。

Edit: I ran it on the emulator and it gives this error in the text view. 编辑:我在模拟器上运行它,它在文本视图中给出此错误。

android.os.NetworkOnMainThreadException android.os.NetworkOnMainThreadException

You got this exception: 您遇到了以下异常:

com.microsoft.sqlserver.jdbc.SQLServerException:The connection to the 
          host server.com, named instance Db_name has failed. 
Error:"Java.net.SocketTimeoutException". Verify the server and the instance names, 
          check that no firewall is blocking UDP traffic to port 1434, and for 
          SQL Server 2005 or later verify that the SQL Server Browser Service 
          is running on the host.

Basically, you need to do what the exception message says: 基本上,您需要按照异常消息的说明进行操作:

  1. Check that you are using the correct server hostname. 检查您使用的服务器主机名是否正确。 (Is it really "server.com"?) (真的是“ server.com”吗?)
  2. Check that you are using the correct instance name. 检查您使用的实例名称是否正确。 (Is it really "Db_name"?) (真的是“ Db_name”吗?)
  3. Check that there is no firewall blocking your access to UDP port 1434 from your device. 检查是否没有防火墙阻止您从设备访问UDP端口1434。
  4. Check that the SQL Server Browser Service is running on "server.com" (or whatever it really is). 检查SQL Server浏览器服务是否正在“ server.com”(或其实际位置)上运行。

A couple of other things to try on your device: 在您的设备上尝试其他几件事:

  • Check that you can do a DNS lookup of "server.com" (or whatever) 检查您是否可以对“ server.com”(或其他内容)进行DNS查找
  • Check that you can "ping" the "server.com" host (or whatever) 检查您是否可以“ ping”“ server.com”主机(或其他)

Basically, there are a number of things that could be wrong, and you need to eliminate them methodically until you find the real cause of the problem. 基本上,有很多事情可能是错误的,您需要有条不紊地消除它们,直到找到问题的真正原因。 We can't do that for you. 我们不能为您做到这一点。


I ran it on the emulator and it gives this error in the text view. 我在模拟器上运行它,并在文本视图中给出了此错误。

   android.os.NetworkOnMainThreadException

This is a different problem. 这是一个不同的问题。

Here's what the javadoc says: 这是javadoc所说的:

"The exception that is thrown when an application attempts to perform a networking operation on its main thread. “应用程序尝试在其主线程上执行网络操作时引发的异常。

This is only thrown for applications targeting the Honeycomb SDK or higher. 仅针对面向Honeycomb SDK或更高版本的应用程序抛出此错误。 Applications targeting earlier SDK versions are allowed to do networking on their main event loop threads, but it's heavily discouraged. 允许以较早版本的SDK为目标的应用程序在其主事件循环线程上进行联网,但不建议这样做。 See the document Designing for Responsiveness ." 请参阅文档“ 响应能力设计 ”。”

In short, you shouldn't do network stuff (including talking to off-platform databases) on the main event thread ... 'cos it is likely to cause the UI to lock up for extended periods. 简而言之,您不应该在主事件线程上进行网络工作(包括与跨平台数据库进行对话)...因为这很可能导致UI锁定较长时间。

您的网址有问题,请使用以下网址格式:

jdbc:sqlserver://server.com\\Db_name;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 与主机 localhost、端口 1433 的 TCP/IP 连接失败 - The TCP/IP connection to the host localhost, port 1433 has failed com.microsoft.sqlserver.jdbc.SQLServerException:与主机本地主机端口1433的TCP / IP连接失败 - com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed 到主机 localhost 的 TCP/IP 连接,端口 1433 失败错误,需要帮助 - The TCP/IP connection to the host localhost, port 1433 has failed error, need assistance 与主机本地主机端口1487的TCP / IP连接失败-Linux 32位 - TCP/IP connection to the host localhost port 1487 has failed - Linux 32 bit 连接失败,但已重新建立。 主机名或IP地址为“*.*.*.*”,服务名或端口号为*** - A connection failed but has been re-established. The host name or IP address is "*.*.*.*" and the service name or port number is *** 错误:与主机的TCP / IP连接失败。 java.net.ConnectException:连接被拒绝:连接 - Error:The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect JDBC 连接失败,错误:到主机的 TCP/IP 连接失败 - JDBC connection failed, error: TCP/IP connection to host failed 与主机的TCP / IP连接失败。 java.net.BindException:已在使用的地址:connect Driver - The TCP/IP connection to the host has failed. java.net.BindException: Address already in use: connect Driver 连接到具有恒定IP和端口的服务器 - Connection to server that has constant IP and port 数据库错误:与主机的TCP / IP连接失败。 java.net.BindException:地址已在使用中:connect - database error : The TCP/IP connection to the host has failed. java.net.BindException: Address already in use: connect
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM