Java应用程序 在连接PostgresDB时,错误解决

① 错误信息
7 06, 2013 3:23:32 午後 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [default] in context with path [/Shop] threw exception [org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (FATAL: pg_hba.conf ���z�X�g"192.168.0.1"�A���[�U"postgres"�A�f�[�^�x�[�X"shop2, SSL�����p���G���g��������������)] with root cause
org.postgresql.util.PSQLException: FATAL: pg_hba.conf ���z�X�g"192.168.0.1"�A���[�U"postgres"�A�f�[�^�x�[�X"shop2, SSL�����p���G���g��������������
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:398)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:173)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:136)

② 原因是Postgres设定文件没做。PostgreSQL服务端监听设置及客户端连接不可以。所以要做设定
  1.  修改服务端/opt/postgresql/data/postgresql.conf文件,将
       listen_address='localhost'  ⇒  listen_address='*'
 2. 修改/opt/postgresql/data/gp_hba.conf文件 在其中增加客户端的ip追加
       # IPv4 local connections: 
        host all all 192.168.0.1/32  md5   
    ⇒   192.168.0.1 是需要访问的客户端的Ip

③ Postgres重启是必要的

你可能感兴趣的:(PostgreSQL)