【问题标题】:SQL server 2008 R2 connection error / androidSQL server 2008 R2 连接错误/android
【发布时间】:2011-11-30 18:26:41
【问题描述】:

我在连接到本地 SQL Server 2008 R2 时遇到问题,

代码如下:

System.out.println("MySQL Connect Example.");
            Connection conn = null;
            String url = "jdbc:jtds:sqlserver://192.168.2.101:1433/INSERTGT";
            String dbName = "podmiot";
            String driver = "net.sourceforge.jtds.jdbc.Driver";


            String userName = "user"; 
            String password = "pass";
            try {
              Class.forName(driver).newInstance();
              conn = DriverManager.getConnection(url+dbName,userName,password);
              System.out.println("Connected to the database");
              int duration = Toast.LENGTH_SHORT;


              Toast.makeText(getApplicationContext(), "Connected to the database", duration);

              conn.close();
              System.out.println("Disconnected from database");
              EditText edit1 = (EditText)findViewById(R.id.editText1);
              edit1.setText("Disconnected from database");

            } catch (Exception e) {
              e.printStackTrace();
              TextView edit1 = (TextView)findViewById(R.id.exception);
              edit1.setText("Problem: " + e.toString());
            }

错误:

当我尝试建立连接时出现错误:java.sql.SQLException: Network error IOException: localhost/127.0.0.1:1433 - connection refused.

对不起我的英语... :) 谢谢帮助

【问题讨论】:

  • 是否有防火墙可以阻止该端口上的流量?
  • 您可能不希望您的用户名/密码出现在问题中

标签: java sql connection


【解决方案1】:

您的服务器允许远程连接吗?

http://forums.asp.net/t/1338911.aspx

【讨论】:

  • 我不确定,因为我下载了这个程序(sql management studio),我什至不能使用它,因为它写在你的链接中......但我也在另一个网站上找到了如何做在 regedit 中,看起来我一切都很好,:/
  • 听起来您可能没有正确的软件。您可以尝试这些链接只是为了确保您拥有服务器。管理工作室只是用来连接服务器。 msdn.microsoft.com/en-us/sqlserver/bb671149
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多