这是我第一次使用java来访问数据库,所以我在这里可能有一个简单的错误,但是当我从远程数据库中检索我的连接时,我有权访问,但我拒绝连接.
这是有问题的代码:
String url = "jdbc:postgresql:url.isformatted.like.this/database";
try {
conn = DriverManager.getConnection(url, "username", "password");
} catch (SQLException e) {
e.printStackTrace();
System.exit(1);
}
Run Code Online (Sandbox Code Playgroud)
(为了隐私起见,删除了用户/通行证和数据库网址)
问题不能是凭据或URL本身,因为我使用它来使用psql从同一个盒子手动登录.我在想它可能是URL的格式化,但是我找不到任何在远程地址上使用psql的例子(它们都是本地主机的东西)
atk*_*atk 12
根据http://www.petefreitag.com/articles/jdbc_urls/有效的网址是
jdbc:postgresql:database jdbc:postgresql://host/database jdbc:postgresql://host:port/database jdbc:postgresql://host:port/database?user=userName&password=pass jdbc:postgresql://host:port/database?charSet=LATIN1&compatible=7.2
你在主持人之前有//吗?
| 归档时间: |
|
| 查看次数: |
6951 次 |
| 最近记录: |