I've been trying to connect from android to Microsoft SQL server's database. But i'm not able to do it. Please help. I've tried so many things. I was using jtds - 1.3.1 i tried using 1.3.0 version also. But still failed. Please help.
public class ConnectionClass {
String ip = "192.168.0.101\\SQLEXPRESS:1433";
String classs = "net.sourceforge.jtds.jdbc.Driver";
String db = "dictionary";
String un = "";
String password = "";
@SuppressLint("NewApi")
public Connection CONN() {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
Connection conn = null;
String ConnURL = null;
try {
Class.forName(classs);
ConnURL = "jdbc:jtds:sqlserver://" + ip + ";"
+ "databaseName=" + db + ";user=" + un + ";password="
+ password + ";";
conn = DriverManager.getConnection(ConnURL);
} catch (SQLException se) {
Log.e("ERRO", se.getMessage());
} catch (ClassNotFoundException e) {
Log.e("ERRO", e.getMessage());
} catch (Exception e) {
Log.e("ERRO", e.getMessage());
}
return conn;
}
}
and i'm getting this error:
E/ERRO: Unknown server host name 'Host is unresolved: 192.168.0.101\SQLEXPRESS'.
I've also tried removing SQLEXPRESS(like this: 192.168.0.101:1033) from above line but then another error is coming.
I've enabled TCP/IP from MS SQL and i've also allowed port 1433 from firewall as well as i've also allowed MS SQL from firewall. MS SQL's allow remote connection is also checked.
Please help. Thanks..