我有使連接到本地SQL Server 2008 R2的問題,SQL Server 2008 R2的連接錯誤/ Android的
這裏是代碼:
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.
對不起,我的英語...... :) Thx求救
有可能會阻止該端口上的信息流的防火牆? – hage
no ..防火牆關閉... – rychu151
您可能不希望您的用戶名/密碼在問題 –