Reputation: 53
I am trying to connect netbeans with postgreSQL. However, it gives connection error even though my username and password is correct. Following code is my persistence.xml. Can you help me please?
<?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>
and this is the error:
Internal Exception: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres"
and i am pretty sure my password is correct because i can log in with the same password to the database.
Upvotes: 1
Views: 3042
Reputation: 935
I've been having similar issues, and tried to fix this in my pg_hba.conf file. This is located here:
/etc/postgresql/9.5/main
I changed the file with the following:
host dbtest user 127.0.0.1/32 trust
The conf file uses the following format: type, database, user, adress, method
The trust method allows a connection without username or password(read more here).
This should fix the problem.
Upvotes: 3