我正在尝试通过我正在创建的Android应用程序连接到Azure数据库,但是我不断收到此特定错误:
Network error IOException: Could not create socket
。
我可以成功连接到我的登录活动数据库,但是如果我在不同的活动上重复使用相同的代码,它将根本无法连接。
我试图重新格式化连接字符串,但问题仍然存在。这是我当前连接的代码,在登录活动中是相同的:
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());
}
非常感谢任何帮助