我正在尝试使用JDBC连接到postgres localhost。
Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost/mydb?user=postgres");
但是,当我设置了无密码凭据时,代码始终会询问我密码。例如,我可以通过输入以下内容连接到终端上的psql:
psql -U postgres -h localhost
并且它连接时无需询问密码。如何在不输入driverManager密码的情况下连接到postgres?
您可以在不指定密码的情况下打开jdbc连接,但是您可能应该为IP套接字配置信任身份验证。在此处查看更多信息。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句