Newrork错误IOException:顶部连接失败,连接失败:ETIMEDOUT

时间:2014-07-14 11:57:10

标签: 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.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);

    }

0 个答案:

没有答案