I am trying to connect to a Postgresql database from Java using the JDBC Driver and would like to use pgpass to authenticate.
My Postgresql server is correctly setup for password authentication and I have a local .pgpass
file; I can connect using psql without having to provide the user's password. However, when I try to open a connection in Java, I get the following error:
org.postgresql.util.PSQLException: The server requested password-based authentication, but no password was provided.
I am using the following code:
String url = "jdbc:postgresql://localhost/test";
Properties props = new Properties();
props.setProperty("user","my_user");
Connection conn = DriverManager.getConnection(url, props);
My question is then: does the Postgres JDBC Driver support pgpass?
The only clue I could find is in SO and seems to indicate that since the driver does not use libpq, then it cannot use pgpass. I can't seem to find an authoritave answer anywhere though.
*
– Superadd