我正在尝试使用JDBC Driver从Java连接到Postgresql数据库,并且想要使用pgpass进行身份验证。Postgresql JDBC驱动程序是否支持Pgpass身份验证?
我的Postgresql服务器正确设置了密码验证,我有一个本地.pgpass
文件;我可以连接使用psql而不必提供用户的密码。然而,当我尝试打开Java中的连接,我收到以下错误:
org.postgresql.util.PSQLException: The server requested password-based authentication, but no password was provided.
我使用下面的代码:
String url = "jdbc:postgresql://localhost/test";
Properties props = new Properties();
props.setProperty("user","my_user");
Connection conn = DriverManager.getConnection(url, props);
我的问题则是:做Postgres的JDBC驱动程序支持pgpass?
我能找到的唯一线索就是在SO中,似乎表明since the driver does not use libpq, then it cannot use pgpass。尽管如此,我似乎无法找到授权答案。