3

I know these types of questions are already there but provided solution is not working for me.In my application there is no version mismatch b/w driver and PostgreSQL server. I have not found any other solution for this.

I am using PostgreSQL server 9.4 and postgresql-9.4-1201.jdbc4.jar.

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="org.postgresql.Driver"></property>
    <property name="username" value="postgres"></property>
    <property name="password" value="root"></property>
    <property name="url" value="jdbc:postgresql://localhost:5432/myapp"></property>
</bean>

pg_hba.conf is as follows:

host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5

postgresql.conf is as follows

listen_addresses = '*'
port = 5432         
max_connections = 100

I have also check the netstat o/p .

TCP    [::]:5432              [::]:0                 LISTENING
TCP    127.0.0.1:5432         0.0.0.0:0              LISTENING

Thanks

7
  • Show the connection string, please. Commented Jun 27, 2015 at 17:56
  • OK. That looks pretty standard. Next thing to check is whether the server is actually up on that port on localhost serving via TCP. Can you also add the contents of pg_hba.conf (the lines which are not commented out), and from postgres.conf, the listen_addresses line if it's not commented out, the port line, and all settings relating to ssl. Commented Jun 28, 2015 at 6:35
  • @RealSkeptic I have provided the details.SSL setting in postgres.conf are commented out. Commented Jun 28, 2015 at 9:46
  • Are you sure you are running the Java program on the same host as the PostgreSQL server? Can you successfully open a socket to port 5432 there? Are you passing the username and password through properties or adding them as parameters to the URL? Commented Jun 28, 2015 at 10:12
  • Yes both java program and postgres are running on my local machine. I am using Spring framework DataManagerDataSource class and passing the properties.See in my question. Commented Jun 28, 2015 at 10:19

1 Answer 1

5

I have faced the same issue.
Just change the port number 5432 to 5433 at postgresql.conf.
Restart your system.

postgresql.conf file location in windows: C:\Program Files\PostgreSQL\9.4\data

Hope it will help you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.