1. 程式人生 > >PostgreSQ 連接問題 FATAL: no pg_hba.conf entry for host

PostgreSQ 連接問題 FATAL: no pg_hba.conf entry for host

body nag 密碼 tar util host etc lmin 本地

PostgreSQ數據庫為了安全,它不會監聽除本地以外的所有連接請求,當用戶通過JDBC訪問是,會報一些如下的異常:

org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host

要解決這個問題,只需要在PostgreSQL數據庫的安裝目錄下找到/data/pg_hba.conf,找到“# IPv4 local connections:”

在其下加上請求連接的機器IP

host all all 127.0.0.1/32 md5

32是子網掩碼的網段;md5是密碼驗證方法,可以改(見文件pg_hba.conf上的說明)......

proxool建立數據庫連接池代碼

/*建立連接池*/

Properties info = new Properties();
info.setProperty(ProxoolConstants.USER_PROPERTY, this.username);
info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, this.password);
info.setProperty(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY, this.prototypeConnections);
info.setProperty(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY, this.poolMinConnections);

info.setProperty(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY, this.poolMaxConnections);

info.setProperty(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY, waitTime);

url = "proxool." + this.dbType + ":" + this.driver + ":"+this.dbURL;
ProxoolFacade.registerConnectionPool(url, info);

/*取連接,其中 this.dbType是連接池的關聯名稱*/

DriverManager.getConnection("proxool." + this.dbType);

PostgreSQ 連接問題 FATAL: no pg_hba.conf entry for host