[英]SQL server 2008 R2 connection error / android
與本地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.
對不起,我的英語... :)謝謝
您的服務器是否允許遠程連接?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.