我有一个IP地址192.168.218.18
每当连接尝试失败时,每次收到消息时,我都尝试了多种方法连接到该服务器。出于安全原因,我已经隐藏了用户名和密码。
代码:
public static void main(String[] args) {
String url = "jdbc:postgresql://192.168.218.18:5432/manikanta?user=*****&password=*****&ssl=true";
try {
Connection conn = DriverManager.getConnection(url);
System.out.println("connection established");
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
}
您应该分别传递用户名和密码,而不是URL的一部分:
public static void main(String[] args) {
String url = "jdbc:postgresql://192.168.218.18:5432/v";
String user = "****";
String password = "*****";
try (Connection con = DriverManager.getConnection(url, user, password);
System.out.println("connection established");
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}