[英]SQL server 2008 R2 connection error / android
I have a problem with making connection to local SQL server 2008 R2, 与本地SQL Server 2008 R2建立连接时出现问题,
here is code: 这是代码:
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());
}
ERROR: 错误:
when I try to make connection I get error: java.sql.SQLException: Network error IOException: localhost/127.0.0.1:1433 - connection refused.
当我尝试建立连接时,出现错误: java.sql.SQLException: Network error IOException: localhost/127.0.0.1:1433 - connection refused.
Sorry for my english... :) Thx for help 对不起,我的英语... :)谢谢
Does your server allow remote connections? 您的服务器是否允许远程连接?
http://forums.asp.net/t/1338911.aspx http://forums.asp.net/t/1338911.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.