Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
2  
If Postgres says: "password authentication failed" then you can be pretty sure that the password is not correct. –  a_horse_with_no_name yesterday
    
however i can use the same password to login the database from postgre's application and it does not give any error. –  user2279774 yesterday
    
Are you sure you log in to the database running on your computer and not some other server? –  a_horse_with_no_name yesterday
    
yeah i am logging in the database which is on my computer and i am also trying to log in to that database from netbeans. –  user2279774 yesterday
    
Either the password isn't really the same, or you're connecting to a different PostgreSQL instance. Check the port and hostname. Look at the server error log of the PostgreSQL server to see if it reports any extra details. If desperate and stuck use wireshark to examine client/server communication. –  Craig Ringer yesterday
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.