我正在使用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