2013-04-24 56 views
0

我剛開始安裝並運行eclipse來訪問psql服務器。並運行Windows 7 32位psql org.postgresql.util.PSQLException:FATAL

我只是在eclipse中設置Web應用程序窗體的基本形式。

在content.xml中的文件,我有

..

<Context path="" debug="5" override="true" reloadable="true"> 
<Resource name="jdbc/connection_pool" 
      description="DB Connection Pool" 
      driverClassName="org.postgresql.Driver" 
      type="javax.sql.DataSource" 
      auth="Container" 
      url="jdbc:postgresql://localhost/students-database" 
      username="postgres" 
      password="1234" 
      defaultAutoCommit="false" 
      maxActive="10" 
      minIdle="0" 
      maxIdle="5" 
      maxWait="3000" 
      removeAbandoned="true" 
      removeAbandonedTimeout="60" 
      logAbandoned="true" 
      validationQuery="SELECT 1" /> 

在DbConnectionPool.jave我有

..

public class DbConnectionPool { 

// Registering Postgresql JDBC driver with the DriverManager 
static { 
    try { 
     Class.forName("org.postgresql.Driver"); 
    } catch (ClassNotFoundException e) { 
     throw new RuntimeException(e); 
    } 
} 

/** 
* Returns a <code>java.sql.Connection</code> object. 
* 
* @exception NamingException 
*    if the JDBC resource is not found 
* @exception SQLException 
*    if a connection can not be obtained 
* 
* @return Connection to use 
*/ 
public static Connection getConnection() throws NamingException, 
     SQLException { 

    // TODO: To be replaced with real connection pool after we have covered it in class 

    return DriverManager.getConnection(
      "jdbc:postgresql://localhost/students-database?" + 
      "user=postgres&password=1234"); 
} 

}

我做到了不是在psql程序中插入的任何數據,

我只是做簡單的JSP文件,當我編譯運行JSP文件

我收到錯誤

org.postgresql.util .PSQLException:FATAL:用戶「postgres」的密碼驗證失敗

我不太確定爲什麼。

當我連接psql程序,我可以看到4 PSQL我目前嘗試使用8.4構建Web應用程序內

enter image description here

我只是想知道爲什麼發生這種情況。我只是沿着方向走,並且發現錯誤的原因。

但無效。

有誰知道如何解決它?

+0

關於「密碼驗證失敗*」的含義尚不清楚? – 2013-04-25 21:42:19

回答

1

我猜你在數據庫上有一個密碼,你需要提供其餘的參數。另外,請確保該文件是context.xml而不是content.xml。