Java Newrork错误IOException:顶部连接到ip失败,连接失败:ETIMEDOUT
我在使用下面的代码时遇到上述错误,我不确定这是否与连接字符串有关?这可能与我没有使用正确的ip有关吗Java Newrork错误IOException:顶部连接到ip失败,连接失败:ETIMEDOUT,java,android,sql,Java,Android,Sql,我在使用下面的代码时遇到上述错误,我不确定这是否与连接字符串有关?这可能与我没有使用正确的ip有关吗 Log.i("Android"," MySQL Connect Example."); Connection conn = null; try { String driver = "net.sourceforge.jtds.jdbc.Driver"; Class.forName(driver).newInstance(); //test = com.m
Log.i("Android"," MySQL Connect Example.");
Connection conn = null;
try {
String driver = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(driver).newInstance();
//test = com.microsoft.sqlserver.jdbc.SQLServerDriver.class;
String connString = "jdbc:jtds:sqlserver://IP/TABLENAME;encrypt=false;user=SECURE\\username;password=password;instance=instance;";
Log.i("Android"," connString");
String username = "secure\\username";
String password = "password";
conn = DriverManager.getConnection(connString,username,password);
Log.w("Connection","open");
Log.i("Android"," Con Open");
Statement stmt = conn.createStatement();
ResultSet reset = stmt.executeQuery("select FeedURL from [dbo].[RSS_Source]");
Log.i("Android"," Query");
//Print the data to the console
while(reset.next()){
Log.w("Data:",reset.getString(3));
// Log.w("Data",reset.getString(2));
}
conn.close();
} catch (Exception e)
{
//Toast.makeText(getApplicationContext(), e.toString(),
//Toast.LENGTH_LONG).show();
Log.i("FAIL", null);
}
服务器或客户端可能被防火墙阻止。。检查一下,不确定,可能是那个。有没有办法从错误消息中获取更多信息?例如,到底是什么原因导致超时?在这两个文件上都写一个日志,您的端口也可能有问题