我正在使用jdbc连接到java应用程序中的postgresql数据库(实际上该应用程序是在Groovy中编写的)。我有postgresql设置使用'信任'认证方法。是否可以在不指定密码的情况下打开jdbc连接?当我尝试使用普通的构造函数使用空白密码时,出现是否可以创建一个没有密码的jdbc连接(使用postgresql'trust')?
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连接另一台机器。 – 2010-05-14 09:34:46
@Milen“信任”认证(即无密码)也可用于ip连接 – leonbloy 2010-05-14 14:54:39
@leonbloy - 请重新阅读我所写的内容。 – 2010-05-14 16:24:32