I am attempting to connect to an Azure database via an android app I am creating, however I keep getting this particular error:
Network error IOException: Could not create socket
.
I can connect to the database on my login activity successfully, but if I reuse the same code on a different activity it will not connect at all.
I have attempted to reformat the connection string, but the problem persists. This is my current code to connect which is the same in the Login Activity:
String username = "username";
String password = "password";
String host = "jdbc:jtds:sqlserver://databaseUrl:1433/database"
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
System.out.println("Connecting to database for duty...");
Connection conn = DriverManager.getConnection(host, username, password);
System.out.println("connected");
} catch (SQLException err) {
System.err.println(err.getMessage());
} catch (Exception e) {
System.err.println(e.getMessage());
}
Any help would be greatly appreciated