【发布时间】:2010-05-14 09:11:32
【问题描述】:
我正在使用 jdbc 连接到 java 应用程序中的 postgresql 数据库(实际上该应用程序是用 Groovy 编写的)。我已将 postgresql 设置为使用“信任”身份验证方法。是否可以在不指定密码的情况下打开 jdbc 连接?当我尝试使用带有空白密码的普通构造函数时,它会失败并显示
Exception in thread "Thread-2" org.postgresql.util.PSQLException: FATAL: password authentication failed for user "myuser"
即使在命令行中,这也可以正常工作
psql -U myuser mydatabase
Welcome to psql 8.3.5, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
【问题讨论】:
-
首先使用 psql 检查身份验证,但来自您尝试连接 JDBC 的同一台机器 - 我感觉“信任”身份验证仅针对本地连接启用,您正在尝试从另一台机器连接 JDBC。
-
@Milen“信任”身份验证(即无密码)也可用于 ip 连接
-
@leonbloy - 请重新阅读我写的内容。
标签: java postgresql jdbc