2014-05-23 3 views
0

netbeans를 postgreSQL에 연결하려고합니다. 그러나 내 사용자 이름과 암호가 맞더라도 연결 오류가 발생합니다. 다음 코드는 내 persistence.xml입니다. 도와 줄수있으세요?PostgreSQL Java 인증 오류

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> 
    <persistence-unit name="travelling" transaction-type="RESOURCE_LOCAL"> 
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
    <class>com.travelling.entity.CbrCase</class> 
    <class>com.travelling.entity.CbrCaseAttraction</class> 
    <class>com.travelling.entity.CbrAttractionXCategory</class> 
    <class>com.travelling.entity.CbrCategory</class> 
    <class>com.travelling.entity.CbrAttraction</class> 
    <class>com.travelling.entity.CbrCaseXCategory</class> 
    <class>com.travelling.entity.CbrDay</class> 
    <class>com.travelling.entity.CbrDayXAttraction</class> 
    <class>com.travelling.entity.CbrAttractionXAttraction</class> 
    <properties> 
     <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> 
     <property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/travelling"/> 
     <property name="hibernate.connection.username" value="*****"/> 
     <property name="hibernate.connection.password" value="*****"/> 
     <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/> 
     <property name="hibernate.show_sql" value="true"/> 
    </properties> 
    </persistence-unit> 
</persistence> 

는이 오류입니다 :

Internal Exception: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres" 

와 나는 데이터베이스에 동일한 비밀번호를 사용하여 로그인 할 수 있기 때문에 비밀번호가 정확한지 확신합니다.

+2

Postgres가 "* password authentication failed *"라고 말하면 비밀번호가 정확하지 않다고 확신 할 수 있습니다. –

+0

그러나 나는 postgre의 응용 프로그램에서 데이터베이스에 로그인하는 데 동일한 암호를 사용할 수 있으며 오류가 발생하지 않습니다. – user2279774

+0

다른 서버가 아닌 * 컴퓨터에서 실행중인 데이터베이스에 로그인 하시겠습니까? –

답변

2

나는 비슷한 문제를 겪어 왔고, 이것을 나의 pg_hba.conf 파일에서 고치려고했다. 이 여기에 있습니다 :

host  dbtest user 127.0.0.1/32 trust 

conf의 파일은 다음과 같은 형식으로 사용합니다 : 유형, 데이터베이스, 사용자, ADRESS을, 방법

/etc/postgresql/9.5/main 

나는 다음으로 파일을 변경 트러스트 메서드는 사용자 이름이나 암호없이 연결을 허용합니다 (more here 읽기).

이렇게하면 문제가 해결됩니다.